0
ボタンをマウスオーバーすると、ホバー効果がボタンのアイコンとラベルを重ねて表示されます。 z-index: 999;
を置いてホバー効果の上にあるアイコン/ラベルdivのレイヤーを移動しようとしましたが、動かない。ホバー効果が重なっているのはなぜですか?
HTML
<div class="service-wrapper">
<div class="services">
<a href="#"><div class="button">
<img src="https://png.icons8.com/?id=42205&size=36" class="iconBtn">
<div class="serv-name">TECHNICAL SUPPORT</div>
</div></a>
</div>
<div class="services">
<a href="#"><div class="button">
<img src="https://png.icons8.com/?id=7495&size=36" class="iconBtn">
<div class="serv-name">CUSTOMER SERVICE</div>
</div></a>
</div>
</div>
CSS
.button {
height: 40px;
width: 230px;
margin: 10px;
padding: 5px;
padding-right: 15px;
padding-left: 15px;
border-radius: 5px;
background: #ffbb11;
text-align: center;
color: #000000;
font-weight: bold;
display: flex;
align-items: center;
justify-content: space-around;
overflow: hidden;
position: relative;
}
a {
text-decoration: none;
}
.button::before,
.button::after {
background: rgba(255, 255, 255, 1.0);
content: '';
position: absolute;
}
.button::after {
height: 70px;
left: -22%;
top: 0;
transform: skew(50deg);
transition-duration: 0.3s;
transform-origin: top;
width: 0;
z-index: 0;
}
.button:hover:after {
height: 60px;
width: 325px;
}
.iconBtn{
max-height: 85%;
max-width: 85%;
}
img:hover: {
z-index: 999;
}
うん、動作します:あなたは、ここで結果を参照してください。私はもともと '.button .iconBtn {z-index:999;}'と '.button .serv-name {z-index:999;}'を持っていました。ありがとうございました。 –
なぜそれはうまくいかないのか分かりません。おそらく 'img:hover:'の後ろに置かれていたのでしょうか。 –