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

前端 未结 6 1578
不思量自难忘°
不思量自难忘° 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:11

    This should work. It is a bad way to do this but if you MUST support IE6 not much choice.

          
    1. 1 Item
      1. 1.1 Item
      2. 1.2 Item
      3. 1.3 Item
      4. 1.4 Item
    2. 2 Item
      1. 2.1 Item

    with css

    ol {list-style:none;}
    

    After your comment I've redone it a bit.

      
    1. 1 Item
      1. 1.1

        ItemItemItem ItemItemItemItemItemItemItemItem ItemItemItemItemItemItemItemItem ItemItemItemItemItemItemItemItem

      2. 1.2

        ItemItemItem ItemItemItemItemItemItemItemItem ItemItemItemItemItemItemItemItem ItemItemItemItemItemItemItemItem

      3. 1.3

        ItemItemItem ItemItemItemItemItemItemItemItem ItemItemItemItemItemItemItemItem ItemItemItemItemItemItemItemItem

      4. 1.4

        Item

    2. 2 Item
      1. 2.1 Item

    And the css would be

    ol {list-style:none;}
    ol li span
    {
      display: block;
      float: left;
      width: 30px;
    }
    ol li
    {
     clear:both;
     width: 400px;
    
    }
    ol li p
    {
      float: left;
      width: 370px;
      margin: 0;
    
    }
    

    You may have to adjust the widths.

提交回复
热议问题