3

I'm trying to apply css for all spans in a specific class but exclude some of them, but the following code doesn't work:

.basket-items li span:not(.name,.count){border:solid 1px #ddd; border-radius:50%;}

I have always used the :not just like :not(:empty). doesn't it accept css classes?

This is the html:

<ul class="basket-items">
    <li>
          <span class="ion-android-close"></span>
          <span class="name"></span>
          <span class="ion-plus"></span>
          <span class="count"></span>
          <span class="ion-minus"></span>
    </li>
</ul>

P.S.: note that in here excluding classes are meant which produce different result than the similar question like: Can I have multiple :not() selectors?

6

2 Answers 2

9

Try Like This,

.basket-items li span:not(.name):not(.count) {
   border:solid 1px #ddd; 
   border-radius:50%;
}
Sign up to request clarification or add additional context in comments.

5 Comments

but this is applied to all the spans in the document.
@Ashkan Mobayen Khiabani: You sure about that?
yes it applies to all the spans (which does not have .name or .count classes)
@Ashkan Mobayen Khiabani: "all the spans which do not have the classes" and "all the spans in the document" are two completely different things. Anyway, if it does apply only to the spans that don't have those two classes... what's the problem?
Sorry. my bad. I had a comma before the second :not
4

.basket-items li span:not(.name):not(.count){border:solid 1px #ddd;}
<ul class="basket-items">
    <li>
          <span class="ion-android-close">Hello</span>
          <span class="name">Hello</span>
          <span class="ion-plus">Hello</span>
          <span class="count">Hello</span>
          <span class="ion-minus">Hello</span>
    </li>
</ul>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.