如此处所示:http://codepen.io/anon/pen/rVPqeL http://codepen.io/anon/pen/rVPqeL
我正在使用 3 个简单的 div,我想获得必须消失的“全局”滚动条的效果over标题。
html是非常基础的
<div class="container">
<div class="header">
</div>
<div class="content">
</div>
</div>
这是CSS:
.container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: gray;
overflow-y: scroll;
}
.header {
position: fixed;
width: 100%;
height: 50px;
background-color: red;
}
.content {
margin-top: 50px;
min-height: 2500px;
background-color: blue;
}
滚动条一直滚动under标题 div。我究竟做错了什么?
我尝试更换position:fixed
with position:sticky
并添加了top:0
它对我来说效果很好,不再有重叠的垂直滚动条。
.header {
position: sticky;
top: 0;
width: 100%;
height: 50px;
background-color: red;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)