开发者

Side element fixes to top of page once scrolled to

开发者 https://www.devze.com 2023-03-09 08:28 出处:网络
I\'m not even sure I\'m describing this properly, but basically I want to display a leaderboard ad the way www.okcupid.com has setup.

I'm not even sure I'm describing this properly, but basically I want to display a leaderboard ad the way www.okcupid.com has setup.

I found this question helpful (http://stackoverflow.com/questions/3303173/position-element-fixed-vertically-absolute-horizontally) but it stays fixed. I would pr开发者_运维知识库efer it to scroll with the page until it reaches the top and then be fixed. Any ideas?


You would use JavaScript.

The element will have normal flow on your page, and when the document.body.scrollTop is larger than the element's y position, give it position: fixed.

0

精彩评论

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

关注公众号