所以我有一个包含一些徽标的 div。当我将鼠标悬停在它们上面时,它们应该变成彩色而不是灰色并弹出,但由于某种原因过渡不起作用。
这是html中div的代码:
<div class="clients">
<img src="img/myob.png">
<img src="img/belimo.png">
<img src="img/LifeGroups.png">
<img src="img/Lilly.png">
<img src="img/Trustly.png">
<img src="img/Citrus.png">
</div>
css代码:
.clients{
width:100%;
height:120px;
background-color: #f1f1f1;
align-items: right;
justify-content: center;
}
.clients img{
display:inline-block;
margin-left: 100px;
width:100px;
height:100px;
padding: 15px 0;
transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
object-fit: contain;
filter: grayscale(100);
}
所以我使用过渡让图像弹出并变成彩色,但是当我悬停在上面时没有反应。
div的图片:
过渡适用于图像。检查以下代码段。
img {
width: 200px;
filter: grayscale(100);
transition: all 0.3s ease;
}
img:hover {
filter: grayscale(0);
}
<span>
<img src="https://assets.dragoart.com/images/11939_501/how-to-draw-iron-man-easy_5e4c9ed9b16b58.14188289_53732_3_3.png" />
</span>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句