Modify TAGs that do not have such class

1

When we want to modify a div, and it has a class such, it is easy.

.umaclass{
   /*Formatação*/
}

But let's suppose I want to get a div that does not have such a class, without modifying the ones that have the class ... How do I do?

For example:

I have several divs with the same class, test and testing :
<div class="teste testando"></div>
<div class="teste testando"></div>
<div class="teste testando"></div>

<div class="teste"></div> //SOMENTE ESSA SER MODIFICADA, SEM MODIFICAR AS OUTRAS

But I want to modify only the test class but without modifying the ones that have the class testing how do I do this?

    
asked by anonymous 24.05.2017 / 19:59

2 answers

3

Anderson Carlos Woss's answer will probably meet your needs, but if you want to know, there is also :not in css, see:

.teste:not(.testando){
  background-color: red;
  height: 50px;
  width: 100px;
}
<div class="teste testando"></div>
<div class="teste testando"></div>
<div class="teste testando"></div>

<div class="teste"></div>

It accepts a simple selector as an argument, and will select all elements that do not fit that selector

    
24.05.2017 / 20:13
2

CSS works from the most generic to the most specific. That is, you can style all div with only div { ... } and then stylize .umaclass overwriting the desired properties.

See an example:

.teste {
  display: none;
}

.testando {
  display: block;
}
<div class="teste testando">1</div>
<div class="teste testando">2</div>
<div class="teste testando">3</div>

<div class="teste">4</div

Note that the last div holds the default styling, set to .teste , while the others have been stylized as .testando .

    
24.05.2017 / 20:04