当光标悬停在顶部的蓝色 block 上时无法滚动,知道我哪里出错了吗?
HTML
<div class="wrapper">
<div class="block">
block
</div>
<div class="content">
content
</div>
</div>
CSS
body {
margin: 0px;
padding: 0px;
}
.block {
background: blue;
height: 300px;
width: 100%;
position: fixed;
}
.content {
background: red;
margin-top: 300px;
top: 0;
width: 100%;
height: 100%;
z-index: 100;
position: absolute;
}
.wrapper {
position: absolute;
width: 100%;
height: 100%;
overflow: auto;
}
JS
$(".wrapper").scrollTop(300);
最佳答案
由于您要为类 block 固定位置,因此它会阻止滚动条工作。所以改变类 block 的位置。
关于html - 无法在顶部 div 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21203540/