Suppose there are two elements vertically placed together, like the following image:
The condition is div1
's height is auto/dynamic, since it depends on its content.
The question is how to set css style of div2
to make sure the sum of heights of div1
and div2
is fixed, for example:
<div1>
and <div2>
has total height of 1000px
, while div1
's height is auto, when div1
has height of 200px
, the height of div2
will auto adjust to 1000-200=800px
; when div1
has height of 400px
, the height of div2
will auto adjust to 1000-400=600px
;
Is there any solution about this? I tried to use flex, but cannot figure out how.