简体   繁体   English

如何在 hover 上制作元素(过渡后)

[英]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:我无法做两件事:

  1. When i hover over an image the image and its label should go above everything (i put a z-index: 10000 but that doesn't work当我 hover 在图像上时,图像及其 label 应该 go 高于一切(我放了一个z-index: 10000但这不起作用
  2. Make the .around image above the.around label. You can see by figure two that hover doesn't work on label div.在.around label上方制作.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;
}

悬停不会超出转换后的元素 标签 div 块将鼠标悬停在图像上

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM