[英]How can I make my disabled button not change color when there's a hover with CSS?
I tried this CSS: 我试过这个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;
}
But still when I hover over the button I see the color change from red to white. 但是当我将鼠标悬停在按钮上时,我看到颜色从红色变为白色。 Note that it's correctly picking up the fact it's disabled. 请注意,它正确地发现了它被禁用的事实。 I am using: 我在用:
disabled="disabled"
in my button. 在我的按钮。
Try .btn:hover:not(:disabled),
试试.btn:hover:not(:disabled),
A small example 一个小例子
Your example didn't work because you are using .btn:hover:not(disabled)
you have to use a pseudo class to achieve what you need reference pseudo classes 您的示例无效,因为您正在使用.btn:hover:not(disabled)
您必须使用伪类来实现您需要的引用伪类
button:hover:not(:disabled){ color:red; }
<button>Not disabled</button> <button disabled>disabled</button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.