表格行的CSS自动编号-不是第一? [英] CSS auto numbers for table rows - not first?

查看:66
本文介绍了表格行的CSS自动编号-不是第一?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,用于将行计数应用于动态表-

I have the following code which is used to apply a row count to a dynamic table -

.ftable table {
    counter-reset: rowNumber;
}

.ftable tr {
    counter-increment: rowNumber;
}

.ftable tr td:first-child::before {
    content: counter(rowNumber);
    min-width: 1em;
    margin-right: 0.5em;
}

来自(为表行自动编号?

是否可以忽略第一行(第一行row是我的标题行-如果有帮助,它具有fble_htr类)

Is it possible to ignore the first row (first row is my header row - which has a class of fble_htr if thats any help)

推荐答案

是:

.ftable tr:not(.fble_htr) {
    counter-increment: rowNumber;
}

.ftable tr:not(.fble_htr) td:first-child::before {
    content: counter(rowNumber);
    min-width: 1em;
    margin-right: 0.5em;
}

而不是 tr:not(.fble_htr),您还可以使用 tr:not(:first-child) tr + tr

Instead of tr:not(.fble_htr), you could also use tr:not(:first-child) or tr + tr.

如注释中所述,如果可以修改HTML,另一种选择是将标题行移到 thead 元素,并将其余行放入 tbody 元素,然后选择 .ftable tbody tr .ftable tr:not(.fble_htr)

As mentioned in the comments, if you can modify your HTML, another option is to move your header row into a thead element, and the rest of the rows into a tbody element, then select .ftable tbody tr instead of .ftable tr:not(.fble_htr).

这篇关于表格行的CSS自动编号-不是第一?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆