开发者

How do I update page height after jquery show()?

开发者 https://www.devze.com 2023-01-26 05:42 出处:网络
I have a div which is supposed to stay at the top of the viewport even when scrolling (position: absolute).

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消