简体   繁体   中英

How can I use a CSS selector to match two classes being present?

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>

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  ----------^ -->

You're looking for this:

.form .input-type-text.disabled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM