开发者

Always-on-top header

开发者 https://www.devze.com 2023-01-29 19:39 出处:网络
I want to add a always-on-top header like the new twitter does. Explanation开发者_开发技巧: When the user scrolls down the page, I want the header to stay on top of the window.

I want to add a always-on-top header like the new twitter does. Explanation开发者_开发技巧: When the user scrolls down the page, I want the header to stay on top of the window.

Somebody know a script that does that? Or can target me how can I do it?


You can use position: fixed; on the header.

<div id="header">
content goes here.
</div>

and the CSS:

#header { position: fixed; z-index: 9999; top: 0; left: 0; }


You need to give your header a position of fixed to make it visible throughout the page. And set the top value appropriately along with width.

Example:

#header{
  position:'fixed';
  top:0;
  width:800px;
}


Use position:fixed on the header in its CSS.

Also, dont forget to set the left and top attributes to where you want it to go :)

0

精彩评论

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

关注公众号