Stretch list items
  • to fill the width of
    • 前端 未结 4 1852
      囚心锁ツ
      囚心锁ツ 2021-02-02 11:00

      I have an unordered list (

        ) with various number of items (
      • ) in it. I want to use one CSS styling that allows the items to stretch t
      相关标签:
      4条回答
      • 2021-02-02 11:21

        Easy solution with

        ul {
            display: flex;
        }
        
        ul li {
            width: 100%;
        }
        
        0 讨论(0)
      • 2021-02-02 11:22
        #ul1 {
        display: block;
        padding: 0;
        list-style: none;
        }
        
        li-Class{
        width: 100%
        }
        

        Note: display can be inline-block with width:100% and this code is for those who are looking to arrange li block wise.

        0 讨论(0)
      • 2021-02-02 11:33

        Demo HI now you can do this

        Used to display :table and display:table-cell

        as like this

        Css

        ul {
            border:1px dotted black;
            padding: 0;
            display:table;
            width:100%;
            box-sizing:border-box;
            -moz-box-sizing:border-box;
            -webkit-box-sizing:border-box;
        }
        li {
            background-color: red;
            display:table-cell;
        }
        li:nth-child(2n) {
            background-color: #0F0;
        }
        

        Now define your parent display:table; or width:100%; and define your child display:table-cell;

        Demo

        0 讨论(0)
      • 2021-02-02 11:34

        I've got the simplest solution. <ul style="padding: 0;"> <li style="list-style-type: none;margin:0;"></li> </ul>

        0 讨论(0)
      提交回复
      热议问题