How to create a 1.1, 1.2 1.3 … HTML list?

前端 未结 6 1583
不思量自难忘°
不思量自难忘° 2021-02-19 23:52

I want to create HTML nested lists that has the following format:

1  
   1.1  
   1.2  
   1.3  
   1.4   
2
   2.1

I tried a solution that I f

6条回答
  •  迷失自我
    2021-02-20 00:21

    You can use counters to do so:

    Example

    ol { counter-reset: item }
    li{ display: block }
    li:before { content: counters(item, ".") " "; counter-increment: item }
    1. li element
      1. sub li element
      2. sub li element
      3. sub li element
    2. li element
    3. li element
      1. sub li element
      2. sub li element
      3. sub li element

提交回复
热议问题