gpt4 book ai didi

html - 我如何让这个 div 中的图像与翻转不覆盖?

转载 作者:太空宇宙 更新时间:2023-11-04 12:27:42 24 4
gpt4 key购买 nike

想知道如何让白色聊天气泡脱离叠加层。

如果还有任何方法可以使用此代码简化此处发生的事情,我也将不胜感激,我相信这已经超出了顶部。

谢谢!

HTML

<a href="#">
<span class="rollover-button"></span>
<div class="the-button"><div class="innerbox"><img src="http://i.stack.imgur.com/QSFeU.png"></div><p>some link</p></div>
</a>

CSS

.rollover-button {
opacity: 0;
background-color: #2570B0;
height: 29px;
width: 175px;
position: absolute;
z-index: 10;
}

.rollover-button:hover {
opacity: .6;
}

.the-button {
background-color: #B5B3BE;
width: 175px;
height:29px;
color: white;
font-weight: bold;
position: relative;
}

.the-button p {
position: absolute;
right: 35px;
top: 5px;
margin: 0;
}

.innerbox {
width: 29px;
height: 29px;
position: absolute;
top: 0px;
left: 0px;
margin: 0;
background-color: #5D6C6B;
}

.innerbox img {
margin: 2px;
width: 25px;
height: 25px;
z-index: 1;
}

最佳答案

z-index 属性 only applies to positioned elements .

因此,如果您希望聊天气泡出现在其他元素之上,您必须对其进行定位。 (即添加 position: relative),然后在这种情况下增加 z-index 值。

Updated Example

.innerbox img {
margin: 2px;
width: 25px;
height: 25px;
z-index: 20; /* Increased from 1 -> 20 */
position: relative; /* Added this.. */
}

position 属性的默认值为 static,这就是它不起作用的原因。

关于html - 我如何让这个 div 中的图像与翻转不覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27892146/

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