我试图给每组随机颜色。 这是我正在处理的网站。这些类(class)不是硬编码的,而是从我们的数据库中获取的。
http://193.191.177.139/agenda.html
这是我尝试过的,因为我不知道如何做随机颜色的事情,但我什至无法让它工作:
.vis-foreground .vis-group .vis-item .vis-item-overflow :nth-child(even) { background: blue;}
.vis-foreground .vis-group .vis-item .vis-item-overflow :nth-child(odd) { background: red;}
有谁知道如何从随机颜色开始?
最佳答案
你不应该在 :nth-child 和选择器之间留出空间。
代码应该是这样的。
.vis-foreground .vis-group .vis-item .vis-item-overflow:nth-child(even) { background: blue;}
或
基于您要定位的选择器
.vis-foreground .vis-group .vis-item:nth-child(even) { background: blue;}
关于css - 每个 div 组的随机颜色 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52703380/