I have a div (.main-div
) that contains two inner div (.title-div
and .body-div
).
They must fit in both direction the size of .main-div
.
.title-div
has a fixed height of 25px
.
Sometimes .title-div
can be hidden. But when I do that my .body-div
goes up but doesn't fit .main-div
because its height property is wrong.
I would like my .body-div
always fit the available space of its parent
.main-div {
height: 150px;
width: 150px;
background-color: lightgray;
border: 1px solid black;
}
.title-div {
height: 25px;
width: 100%;
background-color: lightblue;
}
.body-div {
height: calc(100% - 25px);
width: 100%;
background-color: green;
}
/* from bootstrap*/
.hidden {
display: none !important;
visibility: hidden !important;
}
<div class="main-div">
<div class="title-div">
title
</div>
<div class="body-div">
body
</div>
</div>
Here is a fiddle: https://jsfiddle.net/g8zef0ux/
Any ideas?