Stretch list items
  • to fill the width of
    • 前端 未结 4 1850
      囚心锁ツ
      囚心锁ツ 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: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

      提交回复
      热议问题