[英]How To Change Div To “Fixed” After Scroll
At academicearth's about page, they have an <aside>
tag on the right that is fixed
once you start to scroll. 在Academicearth的About页面上,它们的右侧有一个
<aside>
标记,一旦您开始滚动,该标记就会fixed
。
http://academicearth.org/about/ http://academicearth.org/about/
How is this done? 怎么做?
On top of the <aside>
tag becoming fixed
, it's also moved over just a bit to the right to fit the contents that appear from scrolling. 在
<aside>
标记fixed
,它还向右移一点,以适应滚动显示的内容。
use scroll event.. 使用滚动事件。
$(document).scroll(function(e)
{
//grab position of scrollbar
position=$(document).scrollTop();
//when position match a height
if(position==desired_height)
{
//grab element
$('ele').css('position','fixed');
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.