Three level decimal ordered list CSS

前端 未结 2 1500
孤城傲影
孤城傲影 2021-01-28 03:43

I have a three level ordered list in html that I would like to give a style as following:

1. Item 1
1.1 Item 2
1.1.1 Item 3

An example of the

2条回答
  •  长情又很酷
    2021-01-28 04:14

    Use the following code:

    html:

     
    1. Should be Item 1
      1. Should be Item 1.1
      2. Should be Item 1.2
      3. Should be Item 1.3
        1. Should be Item 1.3.1
      4. Should be Item 1.4
    2. Should be Item 2

    css:

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

提交回复
热议问题