TIL using math to pick CSS child elements
POSTED ON:
TAGS: css
These are some sweet CSS psuedoclass tricks.
/* Select All <li> elements but The First Three */
li:nth-child(n+4) {
color: yellow;
}
/* Select only the first 3 <li> elemets */
li:nth-child(-n+3) {
color: green;
}
/* Styles are elements that are not a <p> */
.my-class:not(p) {
display: none;
}
Related TILs
Tagged: css