.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; }
为什么这只是动画的不透明度,当我悬停,但不是当我离开的对象与鼠标?
解决方法
您只将转换应用于: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; }
演示:http://jsfiddle.net/7uR8z/6/
如果不希望转换影响鼠标悬停事件,而只想要鼠标悬停事件,则可以为:hover状态关闭转场:
.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; }