gpt4 book ai didi

html - 固定 div 100% 宽度重叠滚动条

转载 作者:太空狗 更新时间:2023-10-29 15:10:54 24 4
gpt4 key购买 nike

如此处所示:http://codepen.io/anon/pen/rVPqeL

我正在使用 3 个简单的 div,我想获得一个必须标题的“全局”滚动条的效果。

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;
}

滚动条一直在标题 div 下方移动。我做错了什么?

最佳答案

下面的代码可以解决问题 http://codepen.io/anon/pen/XbOxgp

.container {
background-color: gray;
overflow-y: scroll;
}

.header {
position: fixed;
width: 100%;
height: 50px;
background-color: red;
z-index: 2;
}

.content {
z-index: 1;
width: 100%;
position: absolute;
top: 60px;
min-height: 2500px;
background-color: blue;
}

关于html - 固定 div 100% 宽度重叠滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31860526/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com