有序列表的自定义列表样式

Mic*_*sch 2 css html-lists

是否可以为呈现类似内容的有序列表定义样式

<ol>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
</ol>
Run Code Online (Sandbox Code Playgroud)

(1)第1项

(2)第2项

(3)第3项

Nen*_*car 6

您可以使用css counter:beforepseudo元素来创建此类型的列表.

ol {
  counter-reset: custom;
  list-style-type: none;
}

ol li:before {
  content: '('counter(custom)') ';
  counter-increment: custom;
}
Run Code Online (Sandbox Code Playgroud)
<ol>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
</ol>
Run Code Online (Sandbox Code Playgroud)