【发布时间】:2011-10-22 12:16:06
【问题描述】:
我有一个脚本,它使用 jQuery 和 CSS 在页面滚动时将某些内容放置在页面顶部。但是,当您滚动时,该栏看起来像是在晃动,并且它已固定在 Google Chrome 和 Mozilla Firefox 的浏览器顶部。为什么会这样?
我希望您能理解我要描述的内容。如果没有,请复制并粘贴此代码以及 jQuery 库以了解我的意思:
<style type='text/css'>
body {
height:1000px;
margin:0;
padding:0;
}
#scroller {
position:relative;
top:60px;
width:100%;
background:#CCC;
height:20px;
}
</style>
<script type='text/javascript'>
$(window).load(function() {
$(window).scroll(function() {
if($(window).scrollTop()>60) {
$('#scroller').css('top', $(window).scrollTop());
}
});
});
</script>
<div id="scroller">Some controls</div>
【问题讨论】:
-
这里是设置的例子:jsfiddle.net/nwellcome/6PGZE
标签: javascript html css firefox google-chrome