Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过css对重复html结构的div进行交替着色_Css - Fatal编程技术网

通过css对重复html结构的div进行交替着色

通过css对重复html结构的div进行交替着色,css,Css,这不起作用,我也试过- .tweet-inner .tweet .text-wrapper .text:nth-child(even) { background-color: #FF0000; } 这是有效的- .text:nth-child(even) { background-color: #FF0000; } 但是我希望.text交替着色,而不是整篇文章。 这也不起作用 这把小提琴很好。请让我知道 应该是: article.text:nth-child(even) {

这不起作用,我也试过-

.tweet-inner .tweet .text-wrapper .text:nth-child(even) {
    background-color: #FF0000;
}
这是有效的-

.text:nth-child(even) {
    background-color: #FF0000;
}
但是我希望
.text
交替着色,而不是整篇文章。 这也不起作用

这把小提琴很好。请让我知道

应该是:

article.text:nth-child(even) {
        background-color: #FF0000;
    }
因为您有多个
文章
元素和一个
.text
DIV(您尝试从
文章
中选择第n个
.text
子元素)

试试这个

article:nth-child(even) .text{
  ...
}
试试这个:

article:nth-child(even) .text {
    background-color: red;
}
article:nth-child(even) .text {
    background-color: red;
}
    article:nth-child(even) .tweet .text {
           background-color: #FF0000;
      }