There are many solutions to make the div
fill the height of the remaining space of the browser window. We will discuss these solutions. But first, let’s look at the illustration of what we want to do.
We may use the flexbox property to fill the remaining height.
HTML:
div,
and inside that div
we created two other divs, one with the fixed height and one div which takes up the remaining height.CSS:
Lines 1–5: We set the outer div
properties.
Lines 7–10: We set the background color and height of the div
, which is fixed.
Lines 12–15: We set the properties of the div
, which takes up the remaining height.
We apply the property of tables to utilize the space between the rows and assign some fixed heights to some elements, filling the remaining space with other elements.
HTML:
div
and inside that div
we made two other divs, one with the fixed height and one div
which takes up the remaining height.CSS:
Lines 1-5: We set the outer div
properties.
Line 7-10: We set the background color, display, and height of the div
, which is fixed.
Line 12-15: We set the properties of the div
, which takes up the remaining height.
With the help of absolute positioning, we stretch the div
s between the two given heights.
HTML:
div
, and inside that div
we made two other div
s, one with the fixed height and one div
which takes up the remaining height.CSS:
Lines 1-5: We set the outer div
properties.
Lines 7-10: We set the background color and height of the div
which is fixed.
Lines 12-15: We set the properties of the div
which takes up the remaining height.