Thursday 25 May 2017

css selectors - CSS - First child without certain class

Is it possible to write a CSS rule to select the first child of an element without a specific class?



example:












In this case I would like to select the first span without class ignore.

I tried this, but didn't seem to work:



.common-class:first-child:not(.ignore) {
...some rules...
}


UPDATE:



If I add a class to the parent div named parent-class, a modified version of the selector suggested by Jukka works except when the first span with class ignore comes after the first one without. The above-mentioned selector is the following:




.parent-class > .common-class.ignore + .common-class:not(.ignore) {
...some rules...
}

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...