P
P
p-oleg2021-03-08 15:57:43
css
p-oleg, 2021-03-08 15:57:43

How to make 2 divs (one above the other) the same height?

There are two 100% wide divs, one above the other.
How can I make them the same height without js?
Height means the height of the div that is taller.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Danil Klimov, 2021-03-08
@p-oleg

You put both divs in a block. You give the block such styles.

.block {
  display: grid;
  grid-template-rows: repeat(2, 1fr);
}

https://codepen.io/danil-klimov/pen/VwmEPrq

S
Stefan, 2021-03-08
@MEDIOFF

Push them into one container and set both of them to 50% height, or also through flex, just instead of the flex-basis height.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question