Monday, November 11, 2019

css - How can I select all children of an element except the last child?



How would I select all but the last child using CSS3 selectors?



For example, to get only the last child would be div:nth-last-child(1).


Answer



You can use the negation pseudo-class :not() against the :last-child pseudo-class. Being introduced CSS Selectors Level 3, it doesn't work in IE8 or below:




:not(:last-child) { /* styles */ }

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...