我目前正在尝试在滚动处于某个垂直值时更改 div 的颜色。虽然目前我的滚动似乎没有检测到页面顶部或底部之间的任何内容。
因此,当我点击页面底部时,我会看到 0、1、2、3、4、5 等,而当我点击页面顶部时,它会出现 0、-1、-2、-3 等。所以似乎有在页面的顶部和底部之间没有页面,因为除了页面的顶部或底部之外,不会在任何地方触发滚动。
HTML结构:
<body>
<div id="container">
<div id="post-view">
<div id="cover-image">
<header>
<div class="title">
</div>
<div class="sub-title">
</div>
</header>
</div>
</div>
<div class="suggested">
content in here
</div>
</div>
</body>
jQuery:
$(document).scroll(function() {
var y = $(this).scrollTop();
console.log(y);
});
CSS:
html, body{
height:100%;
width:100%;
background: #ffffff !important;
overflow-x: hidden;
margin:0;
}
header{
width:100%;
border-bottom: 1px solid #cccccc;
background: #333333;
overflow:hidden;
padding:10px 0 0 0 ;
}
#container{
width:100%;
}
非常感谢任何帮助,如果您需要更多信息,请发表评论。谢谢!