[英]I can't get Z-index of child to be higher than parent's
So, simplifying my code, I have three elements.所以,简化我的代码,我有三个元素。 PS: I'm using Bootstrap for positioning.
PS:我正在使用Bootstrap进行定位。
Example: HTML:示例: HTML:
<div class="container game my-5">
<div class="row">
<div class="col square" id="a1" style="height: 40vh;"></div>
<div class="col square" id="a2" style="height: 40vh;"></div>
</div>
<div class="hold-btn w-100 h-100 d-flex align-items-center justify-content-center">
<button class="btn px-4 py-4" id="button">Button</button>
</div>
<div class="row">
<div class="col square" id="a3" style="height: 40vh;"></div>
<div class="col square" id="a4" style="height: 40vh;"></div>
</div>
</div>
CSS: CSS:
.game {
position: relative;
}
#a1 {
background-color: rgb(74, 74, 223);
}
#a3 {
background-color: rgb(231, 56, 56);
}
#a2 {
background-color: rgb(45, 175, 45);
}
#a4 {
background-color: rgb(245, 245, 36);
}
.hold-btn {
position: absolute;
top: 0;
left: 0;
}
.btn {
background-color: rgb(175, 207, 207);
z-index: 100;
}
.square {
cursor: pointer;
}
My problem is: I can't get both the clickable cols AND the button to show on top of the container "game".我的问题是:我无法同时获得可点击的列和按钮以显示在容器“游戏”的顶部。 I've tried using z-index, but with two results:
我试过使用 z-index,但有两个结果:
Any help, please?请问有什么帮助吗? :(
:(
Maybe it's just isolated on the back of its parent.也许它只是在其父母的背面被隔离。
Try the style rule below, it may help:试试下面的样式规则,它可能会有所帮助:
isolation: isolate; // add this rule to element or its parent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.