【发布时间】:2020-07-03 00:37:54
【问题描述】:
我在下面有一个带有相应 css 的 html 表格。这些行来自 tbody 内的 jquery 函数。我想用不同的颜色制作交替行。 (例如,所有偶数行为红色)。我尝试使用 nth-child(even) 但由于它在内部,所以它将它应用于所有身体。我有溢出-y:自动。当我使用 nth-child(even) 时,它仅对偶数行启用滚动条,而不是对所有 tbody。如何在 .以下是我的代码:
CSS:
'''
.table-fixed thead {
width: 100%;
}
.table-fixed tbody tr:nth-child(even) {
height: 300px;
overflow-y: auto;
width: 100%;
background-color: red;
}
.table-fixed thead, .table-fixed tbody, .table-fixed tr, .table-fixed td, .table-fixed th {
display: block;
}
.table-fixed tbody td, .table-fixed thead > tr > th {
float: left;
border-bottom-width: 0;
}
.table-fixed th {
background-color: #e5e5e5;
color: #454545;
}
'''
HTML: '''
<table id="Table1" class="table table-fixed">
<thead>
<tr>
<th class="col-xs-1">Select</th>
<th class="col-xs-1" style="text-align:center;">Id</th>
<th class="col-xs-1" style="text-align:center;">Date</th>
<th class="col-xs-2" style="text-align:center;">Grade</th>
<th class="col-xs-7">Comments</th>
</tr>
</thead>
<tbody id="datagrid_tbody">
</tbody>
'''
【问题讨论】:
标签: html jquery css text-styling