[英]How to make element on top on hover (after transition)
i have a problem for css guru I'm not able to untangle.我有一个 css 大师的问题,我无法解决。
This is the html:这是 html:
<div class="container">
<div class="around">
<img class="depiction around-depiction"/>
<div class="label">A label</div>
</div>
<div class="around">
<img class="depiction around-depiction" />
<div class="label">Another label</div>
</div>
...
<div class="center">
<img class="depiction center-depiction" />
<div class="label">Center label</div>
</div>
</div>
I've applied a transform to .around
element to move in a circle around the .center
element.我已经对
.center
.around
周围移动一圈。
I cannot manage to do two thing:我无法做两件事:
z-index: 10000
but that doesn't workz-index: 10000
但这不起作用.around
image above the.around label. You can see by figure two that hover doesn't work on label div..around
图像。您可以通过图二看到hover在label div上不起作用。 This is the css:这是 css:
.container .circle {
position: absolute;
z-index: 2;
top: 50%;
left: 50%;
margin: calc(-100px / 2);
border-radius: 50%;
}
.center {
border-radius: 50%;
z-index: 1;
position: absolute;
}
.depiction {
border-radius: 50%;
cursor: pointer;
transition: 0.2s;
}
.around-depiction:hover {
transform: scale(4);
z-index: 1000000;
}
.center-depiction:hover {
transform: scale(2);
z-index: 1000000;
}
.label {
opacity: 0;
min-width: 200px;
z-index: -2;
background: white;
border-radius: 10px/20px;
padding: 5px;
border: 1px solid black;
}
.center:hover .label,
.around:hover .label {
opacity: 1;
z-index: 5;
}
.center .label:hover,
.around .label:hover {
opacity: 0;
}
Try adding the z-index with position: relative;
尝试使用
position: relative;
on your image/label.在您的图像/标签上。 z-index doesn't work on the default, which is
position: static;
z-index 在默认情况下不起作用,即
position: static;
https://coder-coder.com/z-index-isnt-working/ https://coder-coder.com/z-index-isnt-working/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.