Apply style to all divs except one specific

I am trying to apply styles to all my divs except one specific one. I am doing this, but this does not work:

#toolbar div[class~="olControlNavigationHistory"]{ float: left; background-repeat: no-repeat; margin: 2px 12px 2px 12px; } 

Therefore, I need to apply this style to all divs in the #toolbar EXCEPT divs with a class called olControlNavigationHistory.

How can i do this? Is it possible?

Thanks in advance!

+7
source share
2 answers

First apply the rule to all divs:

 #toolbar div { float: left; background-repeat: no-repeat; margin: 2px 12px 2px 12px; } 

Then you need to reset the values ​​for a specific case:

 #toolbar div.olControlNavigationHistor { float: none; background-repeat: repeat; margin: 0; } 

Of course, this assumes that the property values ​​that a particular div would have without applying the first rule are the default values ​​(for example, margin: 0 and float: none .)

EDIT: However, in the future, when everyone supports CSS3, you can also simply rewrite your original rule as #toolbar div:not(.olControlNavigationHistory) and it will work correctly and elegantly.

+11
source

I just did the same and found this answer Use: not selector:

 div:not(#div1){ color:red; } 

was published in Apply CSS style for all elements except SPECIFIC ID

+2
source

All Articles