Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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;
}






Source by css-tricks.com #
 
PREVIOUS NEXT
Tagged: #nth #child #css #tricks
ADD COMMENT
Topic
Name
5+2 =