Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.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 带或不带引导的条带化表_Css - Fatal编程技术网

Css 带或不带引导的条带化表

Css 带或不带引导的条带化表,css,Css,如何在表中实现条带化数据行 .dataTable tbody tr.odd{background-color:#000000} .dataTable tbody tr.even{background-color:#ffffff} 那个密码对我不起作用。 如果我用物质化的话,刀锋就完蛋了 大师们,请帮忙 大宗报价 @如果($cat!=null) 审计程序 完成的工作 @否则 @endif @如果($cat!=null) @foreach($dataArray作为$val) {{$val[0]}

如何在表中实现条带化数据行

.dataTable tbody tr.odd{background-color:#000000}
.dataTable tbody tr.even{background-color:#ffffff}
那个密码对我不起作用。 如果我用物质化的话,刀锋就完蛋了

大师们,请帮忙

大宗报价 @如果($cat!=null) 审计程序 完成的工作 @否则

@endif
@如果($cat!=null)
@foreach($dataArray作为$val)
{{$val[0]}
{{$val[1]}
{{$val[2]}
@endforeach
@否则
@foreach($dataArray作为$val)
{{$val[0]}
@endforeach
@恩迪夫

您应该使用td来表示表内容,但也取决于html如何构造表

.dataTable tbody td.odd {
    background-color:#000000
}
.dataTable tbody td.even {
    background-color:#ffffff
}

一种方法是使用:nth-child()。 看看截取的代码,根据用作参数的公式,您有更多的可能性知道如何为行着色

.dataTable tbody tr:n子项(1n){
背景色:#CCC;
}
.dataTable tbody tr:n子级(2n){
背景色:#777;
}

标题1
标题2
标题3
标题4
标题5
第1行第1列
第1行第2列
第1行第3列
第1行第4列
第1行第5列
第2行第1列
第2行,第2列
第2行第3列
第2行第4列
第2行第5列
第3行第1列
第3行第2列
第3行第3列
第3行第4列
第3行第5列
第4行第1列
第4行第2列
第4行第3列
第4行第4列
第4行第5列
第5行第1列
第5行第2列
第5行第3列
第5行第4列
第5行第5列
您可以使用:

tbody tr:nth-child(odd) {
   background-color: green;
}

tbody tr:nth-child(even) {
   background-color: red;
}
如果您有:

<table>
    <tr>
         <td>Row 1 Col 1</td>
         <td>Row 1 Col 2</td>
         <td>Row 1 Col 3</td>
    </tr>
    <tr>
         <td>Row 2 Col 1</td>
         <td>Row 2 Col 2</td>
         <td>Row 2 Col 3</td>
    </tr>
    <tr>
         <td>Row 3 Col 1</td>
         <td>Row 3 Col 2</td>
         <td>Row 3 Col 3</td>
    </tr>
</table>

如果您使用引导程序,您尝试过为表设置条带行:似乎有效。分享你的HTML,可能会给你一个线索。我很抱歉我是stackoverflow的新手,这就是为什么这种格式是不能接受的。
<table>
    <tr>
         <td>Row 1 Col 1</td>
         <td>Row 1 Col 2</td>
         <td>Row 1 Col 3</td>
    </tr>
    <tr>
         <td>Row 2 Col 1</td>
         <td>Row 2 Col 2</td>
         <td>Row 2 Col 3</td>
    </tr>
    <tr>
         <td>Row 3 Col 1</td>
         <td>Row 3 Col 2</td>
         <td>Row 3 Col 3</td>
    </tr>
</table>
 table tr:nth-child(odd) td{ background-color:#000000; }  
 table tr:nth-child(even) td{ background-color:#ffffff; }