Make child divs expand to fill parent div's width

后端 未结 3 500
借酒劲吻你
借酒劲吻你 2021-02-05 11:40

So I have three divs inside one div.

Text
Text
3条回答
  •  梦如初夏
    2021-02-05 12:26

    If you know there will always be three children, you can simply use:

    .parent > .child {
        float: left;
        width: 33%;
    }
    
    .parent {
        overflow: auto; /*or whatever float wrapping technique you want to use*/
    }
    

    If you do not know how many children there are, you will need to use CSS tables, flexbox, or perhaps combine inline-blocks with text-align: justify.

提交回复
热议问题