gpt4 book ai didi

css - Bootstrap 表从某些行进行 strip 化

转载 作者:行者123 更新时间:2023-12-02 03:47:32 26 4
gpt4 key购买 nike

我想让我的表格从第 7 行开始条纹化。

这不起作用:

.table-striped > tbody > tr:nth-child(7n)

最佳答案

你需要这个

.table-striped tbody tr:nth-of-type(2n+7) td {
background: /* your color here */;
}

Codepen Demo

td {
border:1px solid grey;
padding:1em;
}

.table-striped tbody tr:nth-of-type(odd) {
background:none !important;
}

.table-striped tbody tr:nth-of-type(2n+7) {
background:lightgrey !important;
}

/* note !important is only used here for demo purposes. */

/* This seesm to be because the CSS is applied in the wrong order in Snippets */

/* See the Codepen Demo for use without !important */
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />
<table class="table table-striped">
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>

关于css - Bootstrap 表从某些行进行 strip 化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46320403/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com