开发者

"How to Ask" box when typing a question in SO. How do get that scrolling effect? Pure CSS or JS?

开发者 https://www.devze.com 2023-01-26 06:07 出处:网络
I\'m wondering how to make the effect of the tan rectangle as you scroll it follows (some kind of absolute positioning?), check it out:

I'm wondering how to make the effect of the tan rectangle as you scroll it follows (some kind of absolute positioning?), check it out:

https://stackoverflow.com/questions/ask

When scrolling downwards it sticks on the screen. Me like and me want :D

I'd prefer JS targeting an elementID over CSS. If anyo开发者_如何学运维ne can provide a tutorial or even the coding that would be awesome. The cleaner and less strict, the better. Cheers.


It's CSS:

<div id="scroller" style="width: 270px; position: fixed; ">

See http://www.w3.org/TR/CSS2/visuren.html#fixed-positioning for further information.

"position: fixed" is probably what you're after. In your own code you can set the style of an element with JS code directly, or you can set an element class and put position: fixed it in your CSS.

In the future you can look up such things with tools such as Firebug (for Firefox) or inspect tool for Chrome.


Check this jQuery plugin out, it does exactly that along with a nice animation.

0

精彩评论

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