I have a div which is supposed to stay at the top of the viewport even when scrolling (position: absolute).
I have a some hidden elements that I display on demand with jquery function show(). If I show() a long element, I have a scrollbar appearing开发者_JAVA百科. If I scroll the top div doesn't follow the scrolling. It seems the new page height is ignored.
What to do ?
I think you are confusing position:absolute with position:fixed (which is not supported by ie6 - workaround:http://tagsoup.com/cookbook/css/fixed/).
Also, make sure you have position: relative on your parent element.
Just tossing this out there, if you don't need to support IE6, just use position: fixed
with a top:0
instead...no JavaScript required.
精彩评论