Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

how to alternate background colour in html div elements in css

/* to color odd children in parent-container with children of type div */
#parent-container > div:nth-child(odd) {
 background-color:red;
}

/* to color even children in parent-container with children of type div */
#parent-container > div:nth-child(even) {
 background-color:red;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #alternate #background #colour #html #div #elements #css
ADD COMMENT
Topic
Name
3+7 =