如何在CSS中选择此元素? [重复]

时间:2022-11-20 21:29:01

This question already has an answer here:

这个问题在这里已有答案:

How can I select <button> with the class list-group-item and status disabled in CSS ?

如何选择

<button class="list-group-item" disabled>...</button>
<button class="list-group-item">...</button>

Something like ?
button.list-group-item:disabled

就像是 ? button.list组项目:禁用

Thanks.

谢谢。

2 个解决方案

#1


0  

You can also do it with attribute selector:

您也可以使用属性选择器执行此操作:

.list-group-item[disabled] {
  color:red;
}
<button class="list-group-item" disabled>Select me</button>
<button class="list-group-item">But no me</button>

#2


-1  

You are right. To select a disabled element, use the disabled selector:

你是对的。要选择已禁用的元素,请使用禁用的选择器:

:disabled {
    css declarations;
}

#1


0  

You can also do it with attribute selector:

您也可以使用属性选择器执行此操作:

.list-group-item[disabled] {
  color:red;
}
<button class="list-group-item" disabled>Select me</button>
<button class="list-group-item">But no me</button>

#2


-1  

You are right. To select a disabled element, use the disabled selector:

你是对的。要选择已禁用的元素,请使用禁用的选择器:

:disabled {
    css declarations;
}