html - 使用 row_number CSS 后为 RTL 内容添加填充

标签 html css css-tables css-counter cellpadding

我使用下面的 CSS 代码将行号添加到表格行:

table {
    direction: rtl;
    counter-reset: line-number;
}

td:first-child {
    text-align: right !important;
}

td:first-child:before {
    content: counter(line-number) ".";
    counter-increment: line-number;
    padding-right: 0.3em;
    color: lightgray;
}

但是它的内容在第十行之后没有对齐。见下图:

row number padding issue

但是我想要这样的东西:

row_number2

我也尝试添加 padding 但它不是一个可行的解决方案。

如何解决这个问题?

这是我的 Fiddle现在。

最佳答案

您可以设置 td:first-child:beforemin-width

td:first-child:before {
content: counter(line-number) ".";
counter-increment: line-number;
padding-right: 0.3em;
color: lightgray;
min-width: 20px;
display: inline-block;
}

关于html - 使用 row_number CSS 后为 RTL 内容添加填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38890382/

相关文章:

css - 表 - 现在换行成两行?

css - 样式表 - 表布局 :fixed vs td-width:20%

javascript - Window.print 抛出程序停止错误

jquery - float 菜单的固定定位以支持移动浏览器

html - 为 SVG 图像设置动画,就好像它在绘制自己一样

javascript - 创建一个以视频为背景的部分 HTML5

html - 当上面有图像时,为什么我的文本会超出其容器?

php - 如何在 WordPress 中集成 Photoshop 设计?

jquery - Owl Carousel 自动播放在鼠标悬停时无法正常工作?

html - Internet Explorer 8 未完成页面下载!