【发布时间】:2017-04-08 10:32:37
【问题描述】:
我正在使用数据表来播种数据,我想为前 3 行设置不同的颜色,第一行应该是 green 第二行是 blue,第三行颜色应该是 红色
我的表结构如下
<script>
$(document).ready(function() {
$(document).ready(function() {
$('#project').DataTable({
"columnDefs": [
{ "orderable": false, "targets": [0,6,7] }
]
});
});
});
</script>
<table class="table table-striped table-bordered table-hover table-checkable order-column dataTable no-footer" id="project" class="color">
<thead>
<tr role="row">
<th style="display:none"></th>
<th>Sr</th>
<th>Reg #</th>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach($results as $index => $result)
<tr>
<td style="display:none"></td>
<td>{{ $index+1 }}</td>
<td class="sorting_1"> {{ $result->reg_no }} </td>
<td>{{ $result->first_name }}</td>
</tr>
@endforeach
</tbody>
</table>
我试图为第一行赋予样式
.color td {
background-color : green;
}
但不工作请帮忙解决
谢谢
【问题讨论】:
-
.color 用于完整的餐桌仪式?你现在得到了什么?
-
使用 css 子选择器?
-
不是现在如何使用@ayan
-
@GowthamShiva 没有效果
-
@recovery men,类似于
tr:nth-child(1)