How do I keep two side-by-side divs the same height?

后端 未结 22 2758
自闭症患者
自闭症患者 2020-11-21 07:56

I have two divs side by side. I\'d like the height of them to be the same, and stay the same if one of them resizes. I can\'t figure this one out though. Ideas?

To c

22条回答
  •  余生分开走
    2020-11-21 08:21

    Flexbox

    With flexbox it's a single declaration:

    .row {
      display: flex; /* equal height of the children */
    }
    
    .col {
      flex: 1; /* additionally, equal width */
      
      padding: 1em;
      border: solid;
    }
    Lorem ipsum dolor sit amet, consectetur adipisicing elit.
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad omnis quae expedita ipsum nobis praesentium velit animi minus amet perspiciatis laboriosam similique debitis iste ratione nemo ea at corporis aliquam.

    Prefixes may be required for older browsers, see browser support.

提交回复
热议问题