Search
 
SCRIPT & CODE EXAMPLE
 

CSS

nth child css tricks

Select Only the Fifth Element

li:nth-child(5) {
    color: green;   
}


Select All But The First Five

li:nth-child(n+6) {
    color: green;   
}


Select Only The First Five

li:nth-child(-n+5) {
    color: green;   
}


Select Every Fourth, Starting At The First

li:nth-child(4n-7) {  /* or 4n+1 */
    color: green;   
}




Select Only Odd or Even

li:nth-child(odd) {
    color: green;   
}

li:nth-child(even) {
    color: green;   
}


Select The Last Element

li:last-child {
    color: green;
}


Select the Second to Last Element

li:nth-last-child(2) {
    color: green;
}






Comment

PREVIOUS NEXT
Code Example
Css :: add white background to svg 
Css :: css scrollbar always visible 
Css :: remove border svg 
Css :: overflow scrollbar with variable height 
Css :: tailwind @apply 
Css :: how to style submit button css 
Css :: image rotate css 
Css :: style scrollbar overflow-y 
Css :: move element in front of another css 
Css :: set border only left and right css 
Css :: how to add a background color in css 
Css :: bash list all npm processes 
Css :: force aspect ratio div 
Css :: css image overflow 
Css :: grid blocks center 
Css :: button edges rounded css 
Css :: css animate border bottom on hover 
Css :: how to center a div element 
Css :: best box shadow 
Css :: css checkbox':checked change color 
Css :: css using the same background-color as the parent background 
Css :: remove the outline from bootstrap input and input fields 
Css :: Timeout for a fetch 
Css :: css style placeholder 
Css :: html css make p div into two lines 
Css :: put gradient color over background image 
Css :: placeholder color 
Css :: css selector label for 
Css :: css inverted border radius 
Css :: center div with flexbox 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =