我可以停止:hover应用于元素吗? [英] Can I stop :hover from being applied to an element?
本文介绍了我可以停止:hover应用于元素吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一些CSS ...
Let's say I have some CSS...
button:hover {font-weight:bold}
如何防止随意使用:hover
样式?我的目标用例是禁用该元素时。例如,使用此HTML ...
How can I prevent the :hover
styles from being applied, at will? My target use case is when the element is disabled. For example, with this HTML...
< button disabled> Click me< / button>
... :hover
CSS仍然适用。该按钮逐渐淡出,但是:hover
效果仍然可见。
...the :hover
CSS is still applied. The button gets faded out but the :hover
effect can still be seen. How can this be stopped?
推荐答案
指针事件:没有一个将禁用所有悬停行为。对于禁用元素非常有用
pointer-events: none will disable all hover behavior. very usefull for disabled elements
button[disabled] {
pointer-events: none;
}
这篇关于我可以停止:hover应用于元素吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文