我使用下面的 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;
}
但是它的内容在第十行之后没有对齐。见下图:
但是我想要这样的东西:
我也尝试添加 padding
但它不是一个可行的解决方案。
如何解决这个问题?
这是我的 Fiddle现在。
最佳答案
您可以设置 td:first-child:before
的 min-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/