Equal height for two divs

前端 未结 5 1880
梦谈多话
梦谈多话 2020-12-21 05:20

I have 2 divs (6 columns each). In the div on the left is an image, in the div on the right is some quote. I want my right div\'s height to be the same as height of image.

5条回答
  •  离开以前
    2020-12-21 06:01

    You can make the container of both divs a flexbox, which will automatically apply equal heights to the child elements.

    Try this:

    .row { display: flex; }
    

    Revised Codepen

    By making .row a flex container, the children (.image and .quote) become flex items, and share equal height by default. See here for more details: https://stackoverflow.com/a/33815389/3597276

提交回复
热议问题