如何使用CSS选择器匹配存在的两个类?(How can I use a CSS selector to match two classes being present?)

我有以下HTML:

<div class="form">
<input disabled="disabled" data-ng-model="dataId" type="text" />
<div class="disabled input-type-text">123</div>
</div>
 

我试图匹配禁用类和输入类型文本。 我尝试了以下但它不起作用:

.form .input-type-text.disabled ,
.form input.disabled,
.form input:disabled,
.form select.disabled,
.form select:disabled,
.form textarea.disabled {
  color: #000000;
  background-color: #e6e6e6;
  border: 1px solid #adcede;
  opacity: 0.5;
}
 

有人可以给我一些关于如何与CSS选择器匹配的建议吗? 请注意,这适用于<input>但不适用于<div>

I have the following HTML:

<div class="form">
<input disabled="disabled" data-ng-model="dataId" type="text" />
<div class="disabled input-type-text">123</div>
</div>
 

I am trying to match the class of disabled and input-type-text. I tried the following but it does not work:

.form .input-type-text.disabled ,
.form input.disabled,
.form input:disabled,
.form select.disabled,
.form select:disabled,
.form textarea.disabled {
  color: #000000;
  background-color: #e6e6e6;
  border: 1px solid #adcede;
  opacity: 0.5;
}
 

Can someone give me some advice on how I can match with CSS selectors? Note that this does work for the <input> but not for the <div>

最满意答案

选择器是正确的:

.form .input-type-text.disabled { border: 1px solid #adcede; padding: 7px; margin: 7px 0 2px 0; line-height: 16px }

问题是你没有关闭" in style属性:

<div class="..." style="...ding: 7px; margin: 7px 0 2px 0; line-height: 16px></div> <!-- Here ----------^ -->

The selector is correct:

.form .input-type-text.disabled { border: 1px solid #adcede; padding: 7px; margin: 7px 0 2px 0; line-height: 16px }

The issue is that you don't close " in style attribute:

<div class="..." style="...ding: 7px; margin: 7px 0 2px 0; line-height: 16px></div> <!-- Here ----------^ -->

更多推荐