I have a parent div whose height is dynamically set, so it could change based on user setting. now I have a child div inside it and I want to set the content of that div in such a way that with the change in height of parent's div, the content should still be within the defined specs.
For example: I want: padding: 40px 54px 54px;
to be around the child div regardless what height has the parent been set to.
HTML:
<div class="parent" style="height:180px">
<div class="child">
<header>title</header>
<div>test11</div>
<button>
Test
</button>
<button>
Cancel
</button>
</div>
</div>
CSS:
.parent {
max-height: 300px;
margin: 0 auto;
background-color: #fff;
position: fixed;
top: 20%;
left: 20%;
border: 1px solid #000;
width: 234px;
}
.child {
padding: 40px 54px 54px;
height: 86px;
}
fiddle: https://jsfiddle.net/5thk641u/15/
From the above fiddle you can see that when I try to change the height of parent class from 180px
to 250px
, the bottom padding increases and so does the distance from the buttons to the parent div.
what I want to achieve is when I change the height of the parent, the height of the child div to increase relatively so that the buttons and other content maintains its padding.
I'm not sure of this is achievable or not, any thoughts on this?