gpt4 book ai didi

CSS:鼠标移开时的过渡不透明度?

转载 作者:行者123 更新时间:2023-11-28 00:51:54 25 4
gpt4 key购买 nike

.item:hover {
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
-webkit-transition: opacity .15s ease-in-out;
-moz-transition: opacity .15s ease-in-out;
-ms-transition: opacity .15s ease-in-out;
-o-transition: opacity .15s ease-in-out;
transition: opacity .15s ease-in-out;
}

为什么这只在我将鼠标悬停在对象上而不是在我用鼠标离开对象时动画不透明度?

此处演示:https://jsfiddle.net/7uR8z/

最佳答案

您仅将转换应用到 :hover 伪类,而不是元素本身。

.item {   
height:200px;
width:200px;
background:red;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}

.item:hover {
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
}

演示:https://jsfiddle.net/7uR8z/6/

如果您不希望转换影响 mouse-over 事件,而只希望影响 mouse-out,您可以为 关闭转换:悬停 状态:

.item:hover {
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none;
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
}

演示:https://jsfiddle.net/7uR8z/3/

关于CSS:鼠标移开时的过渡不透明度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53169996/

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