Nested Orderd List with combination of numbers, alphatets and roman numerals for numbering?

前端 未结 2 1152
余生分开走
余生分开走 2021-01-12 08:41

I want to create an ordered list that looks like this:

1. Item_1
2. Item_2:
    a. Subitem_1
    b. Subitem_2:
        I. Sub-Subitem_1
        II. Sub-Subit         


        
2条回答
  •  误落风尘
    2021-01-12 09:04

    This is certainly possible, given the following HTML:

    1. Item_1
    2. Item_2:
      1. Subitem_1
      2. Subitem_2:
        1. Sub-Subitem_1
        2. Sub-Subitem_2
      3. Subitem_3
    3. Item 3

    And the CSS:

    ol {
        list-style-type: decimal;
    }
    
    ol > li > ol {
        list-style-type: lower-alpha;
    }
    
    ol > li > ol > li > ol {
        list-style-type: upper-roman;
    }
    

    JS Fiddle demo.

    Or, you can be less strict about the specificity of the CSS selectors:

    ol {
        list-style-type: decimal;
    }
    
    ol ol {
        list-style-type: lower-alpha;
    }
    
    ol ol ol {
        list-style-type: upper-roman;
    }
    

    JS Fiddle demo.

    References:

    • list-style-type.

提交回复
热议问题