简体   繁体   English

在SO中键入问题时,在“如何提问”框中输入。 如何获得滚动效果? 纯CSS还是JS?

[英]“How to Ask” box when typing a question in SO. How do get that scrolling effect? Pure CSS or JS?

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 https://stackoverflow.com/questions/ask

When scrolling downwards it sticks on the screen. 向下滚动时,它会停留在屏幕上。 Me like and me want :D 我喜欢,我想要:D

I'd prefer JS targeting an elementID over CSS. 与CSS相比,我更喜欢JS针对elementID的定位。 If anyone can provide a tutorial or even the coding that would be awesome. 如果有人可以提供教程甚至是编码,那将是很棒的。 The cleaner and less strict, the better. 越干净越严格,越好。 Cheers. 干杯。

It's CSS: 它是CSS:

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

See http://www.w3.org/TR/CSS2/visuren.html#fixed-positioning for further information. 有关更多信息,请参见http://www.w3.org/TR/CSS2/visuren.html#fixed-positioning

"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. 在您自己的代码中,您可以直接使用JS代码设置元素的样式,也可以设置元素类并放置位置:将其固定在CSS中。

In the future you can look up such things with tools such as Firebug (for Firefox) or inspect tool for Chrome. 将来,您可以使用Firebug(适用于Firefox)之类的工具查找此类内容,也可以使用Chrome浏览器的检查工具。

出这个jQuery插件 ,它和一个漂亮的动画完全一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM