MouseOver和MouseOut在CSS中 [英] MouseOver and MouseOut In CSS
问题描述
对于使用鼠标到一个元素,我们使用:hover
CSS属性。如何将鼠标移出元素?
For using mouse into one element we use the :hover
CSS attribute. How about for mouse out of the element?
我在元素上添加了一个过渡效果来改变颜色。悬停效果工作正常,但我应该使用什么CSS属性鼠标出来应用的效果?我正在寻找一个CSS解决方案,而不是JavaScript或JQuery解决方案。
I added a transition effect on the element to change the color. The hover effect works fine, but what CSS attribute should I use for mouse out to apply the effect? I'm looking for a CSS solution, not a JavaScript or JQuery solution.
推荐答案
这里是最好的解决方案,我想。
Here is the best solution, i think.
CSS onomouseout:
div:not( :hover ){ ... }
CSS onmouseover:
div:hover{ ... }
这是更好,因为如果你需要设置一些样式只有onmouseout,并尝试这样做这样
It's better, because if you need to set some styles ONLY onmouseout and trying to do this in this way
div { ... }
您将设置您的样式和onmouseover 。
you will set your styles and for onmouseover too.
这篇关于MouseOver和MouseOut在CSS中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!