【问题标题】:CSS :: Reduce number with calcCSS :: 使用 calc 减少数字
【发布时间】:2017-08-18 14:52:59
【问题描述】:

css 脚本运行良好:

table
{
    counter-reset:rowNumber;
}

table tr
{
    counter-increment:rowNumber;
}

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

但问题是我想从 rowNumber 中减少 -1(或其他选项将计数器重置为 -1)

我试过这个:

content:counter(calc(rowNumber-1));

但是好像不行

【问题讨论】:

  • 我想这是一个选择... table tr:not(:first-child) { counter-increment: rowNumber; }
  • 我第一次在这里问问题并回答自己:P
  • 我通过以下方式解决了它:table tr:not(:first-child){counter-increment:rowNumber;} 但我很高兴听到不同的方法来解决这个问题,只是为了增加我的 css知识:)

标签: html css numbers css-tables calc


【解决方案1】:

我喜欢使用相邻的兄弟选择器,如下所示:

table tr + tr { /* attributes */ }

这与table tr:not(:first-child) 完全相同,但我经常将它用于任何列表。

ul li + li { margin-top: 1em }

【讨论】:

    猜你喜欢
    • 2013-07-20
    • 2020-12-19
    • 2022-01-01
    • 1970-01-01
    • 2017-09-18
    • 2016-03-29
    • 1970-01-01
    • 1970-01-01
    • 2014-03-21
    相关资源
    最近更新 更多