css 每个子元素不同颜色有很多个
可以使用伪类选择器来为每个子元素设置不同的颜色。例如,使用:nth-child()选择器来选择每个子元素,并为它们设置不同的背景颜色。示例代码如下:
.parent div:nth-child(1) {
background-color: red;
}
.parent div:nth-child(2) {
background-color: blue;
}
.parent div:nth-child(3) {
background-color: green;
}
/* ... */
这样每个子元素都会有不同的背景色,可以根据需要添加更多的子元素样式。
原文地址: https://www.cveoy.top/t/topic/DGJ 著作权归作者所有。请勿转载和采集!