📜  如何在 css 代码示例中的 html div 元素中交替背景颜色

📅  最后修改于: 2022-03-11 14:47:51.394000             🧑  作者: Mango

代码示例1
/* 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;
}