Custom list style for ordered lists

2019-02-28 21:57发布

Is it possible to define a style for an ordered list that renders something like

<ol>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
</ol>

as

(1) Item 1

(2) Item 2

(3) Item 3

1条回答
我命由我不由天
2楼-- · 2019-02-28 22:14

You can use css counter and :before pseudo-element to create this type of list.

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

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

查看更多
登录 后发表回答