gpt4 book ai didi

html - 具有绝对位置的 div 不会与相对位置的 div 重叠

转载 作者:太空宇宙 更新时间:2023-11-03 23:31:01 25 4
gpt4 key购买 nike

HTML:

<div class="absolute">
</div>
<div class="relative">
</div>

CSS:

* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
width: 100%;
}
.relative {
position: relative;
background-color: #eee;
height: 200px;
width: 100%;
}
.absolute {
background-color: #000;
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100%;
}

jsfiddle:http://jsfiddle.net/Lv96zy10/

如何使用相对位置做 div 的位置在 div 之上?

提前致谢。

最佳答案

使用z-index 控制堆叠顺序。

给你想要的 div 一个更高的 z-index 数字。

关于html - 具有绝对位置的 div 不会与相对位置的 div 重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25327701/

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