Divide Width of Element Between Child Divs With CSS

前端 未结 4 1165
南笙
南笙 2021-02-01 18:31

I have a varying number of inline-block divs that I want to collectively take up 100% of their parent. Can this be done without JavaScript? The only way I can think o

4条回答
  •  借酒劲吻你
    2021-02-01 18:53

    You can utilize css3 benefits here. I was also facing this issue now i have fixed that using below example code

    .parent-container {
      padding: 0;
      margin: 0;
      list-style: none;
      display: -webkit-box;
      display: -moz-box;
      display: -ms-flexbox;
      display: -webkit-flex;
      display: flex;
      -webkit-flex-flow: row wrap;
      justify-content: space-around;
      -webkit-justify-content: space-around;
      flex-wrap: nowrap;
      -webkit-flex-wrap: nowrap;
    }
    .child-item {
      margin: 5px;
      text-align: center;
      padding: 10px;
      background-color: red;
      color: #fff;
    }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    Thanks & Regards, Lingeshram

提交回复
热议问题