我尝试了这个CSS:
html.dark .btn:hover:not(disabled),
html.dark .btn:focus {
color: #ffffff;
background-color: #222222;
*background-color: #151515;
}
html.dark .btn.disabled,
html.dark .btn[disabled] {
color: red;
background-color: #222222;
*background-color: #151515;
}
但是当我将鼠标悬停在按钮上时,我仍然看到颜色从红色变为白色。请注意,它正确地了解了它已被禁用的事实。我在用:
disabled="disabled"
在我的按钮上。
尝试 .btn:hover:not(:disabled),
一个小例子
您的示例不起作用,因为您使用的.btn:hover:not(disabled)
是必须使用伪类来实现所需的引用伪类
button:hover:not(:disabled){
color:red;
}
<button>Not disabled</button>
<button disabled>disabled</button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句