Html 将ol列表编号排列到左侧
是否可以将ol列表编号(两位数)从左侧开始排列 通常是这样的Html 将ol列表编号排列到左侧,html,css,html-lists,Html,Css,Html Lists,是否可以将ol列表编号(两位数)从左侧开始排列 通常是这样的 1 2 . . 10 12 但我需要这样的表现 1 2 . . 10 12 您可以使用CSS计数器: CSS: ol { padding-left: 40px; list-style: none; counter-reset: number; } ol li:before { display: inline-block; content: counter(number) '.';
1
2
.
.
10
12
但我需要这样的表现
1
2
.
.
10
12
您可以使用CSS计数器: CSS:
ol {
padding-left: 40px;
list-style: none;
counter-reset: number;
}
ol li:before {
display: inline-block;
content: counter(number) '.';
counter-increment: number;
width: 30px;
}
这种方法唯一的问题是数字区域的宽度是固定的,因此它不会随着元素数量的增加而扩展
演示:可能是您可以使用计数器-增量进行此操作。这样写:
ul{ counter-reset: chapter 0; }
li:before{
counter-increment: chapter;
content:counter(chapter) ". ";
width:20px;
display: inline-block;
text-align: right;
}
勾选此项您能澄清您的问题吗?默认情况下,数字向右浮动:。计数器对CSS3来说并不陌生。@BoltClock:嗯,我一直以为它们是。谢谢你的提示!