gh0*_*0st 2 css twitter-bootstrap
我想稍微修改bootstrap,以便我的条纹行就是这样.
第1行和第2行共享相同的行背景颜色,第3行和第4行共享相同的背景颜色,第5行和第6行共享与第1行和第2行相同的背景颜色.是否存在快速入侵/技巧这种?
这是我到目前为止的代码.
<table class="table table-striped table-sm">
<thead class="thead-default">
<tr>
<td>Column 1</td><td>Column 2</td>
</tr>
</thead>
<tbody>
<template ngFor let-loop [ngForOf]="model | async">
<tr>
<td>Column Data</td><td>Column Data</td>
</tr>
<tr>
<td>Column Data</td><td>Column Data</td>
</tr>
</template>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
.yourTableClass tr:nth-child(4n+1), .yourTableClass tr:nth-child(4n+2) {
background: pink;
}
Run Code Online (Sandbox Code Playgroud)
我不明白您是否希望每个组中的颜色相同或不同,但正如@mayersdesign 所示,请使用nth-childCSS 选择器...
.table tbody tr:nth-child(4n+1), .table tbody tr:nth-child(4n+2) {
background: #aaa;
}
.table tbody tr:nth-child(8n+1), .table tbody tr:nth-child(8n+2) {
background: #ccc;
}
Run Code Online (Sandbox Code Playgroud)
http://www.codeply.com/go/h1TDRedlMR