Set the width of children to fill the parent

后端 未结 7 1096
日久生厌
日久生厌 2020-12-19 11:46

I want the children of the div fill its width.

now am using a code like this:

7条回答
  •  臣服心动
    2020-12-19 12:08

    You can achieve this using flexbox properties.

    Here is a demo:

    .parent {
      display: flex;
      height: 120px;
      background: #000;
      padding: 10px;
      box-sizing: border-box;
    }
    
    .child {
      height: 100px;
      background: #ffffd;
      flex: 1;
      margin: 0 10px;
    }

提交回复
热议问题