How to make two floating divs the same height with CSS?

Spread the love

Sometimes, we want to make two floating divs the same height with CSS.

In this article, we’ll look at how to make two floating divs the same height with CSS.

How to make two floating divs the same height with CSS?

To make two floating divs the same height with CSS, we use flexbox.

For instance, we write

.parent {
  display: flex;
  flex-wrap: wrap;
}

.child {
  flex-grow: 1;
  flex-basis: 50%;
}

to make the element with class parent a flex container with display: flex;.

Then all the child elements will have the same height with flex-grow: 1;.

Conclusion

To make two floating divs the same height with CSS, we use flexbox.

Leave a Reply

Your email address will not be published. Required fields are marked *