我在顶部固定了一个div,在其下方固定了一个div内容。
当我滚动页面时希望div content
超过div top
时,我将z-index放在div内容中,但是什么也没发生...
#top{
top:0;
width:100%;
height:100px;
position:fixed;
border:1px solid #000;
background:black;
}
#content{
background:red;
margin-top:120px;
height:5000px;
z-index:300000;
}
html
<div id=top></div>
<div id=content></div>
我需要div top固定并且内容相对。
怎么了?
https://jsfiddle.net/y97o6kaL/
最佳答案
将z-index: -1;
赋予#top
将对您有用。
#top{
top:0;
width:100%;
height:100px;
position:fixed;
border:1px solid #000;
background:black;
z-index: -1;
}
Working Fiddle
关于css - 在div上固定的div上的div内容?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35360068/