将罗马数字样式应用于计数器输出

CSS

body {
  counter-reset: item-counter;
}

.item {
  counter-increment: item-counter;
}

.item:before {
  content: counter(item-counter, upper-roman) ". "; /* by specifying the upper-roman as style the output would be in roman numbers */
}

HTML

<div class='item'>Item No: 1</div>
<div class='item'>Item No: 2</div>
<div class='item'>Item No: 3</div>

在上面的例子中,计数器的输出将显示为 I,II,III(罗马数字),而不是通常的 1,2,3,因为开发人员明确指定了计数器的样式。