我有这个页面,我希望能够在该页面上包含一个弹出窗口。
如果单击“发现”,您会看到弹出窗口位于三个标题的下方。
标题位于与弹出窗口同级的容器中。
//pop up
<section id="header" class ="collapsed">
<h3>About</h3>
<div id="dismiss">OK</div>
</section>
//titles
<div id="visual">
<h3 id="channel"> Which channel brought the most customers? </h3>
<h3 id="performance"> Which channel offered the best performance?</h3>
</div>
我将弹出窗口设置为 absolute
位置。我还将标题设置为 absolute
和 left: 52%
的位置,这样它们就会停留在屏幕左侧的正确位置。
是否可以让一个绝对 div 覆盖另一个?
最佳答案
给你的#header
div一个z-index
:
#header {
position: absolute;
left: 65%;
top: 1%;
z-index: 1;
}
或者将它移动到#visual
之后的页尾。继续阅读 stacking context和 stacking without the z-index property
关于html - 我可以将一个 div 放在另一个设置为 `position: absolute` 的 div 上吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56011145/