Is there a way to adjust the height of the parent element that has a relative position based on the height of child elements with absolute position?
In the example below, the height of the .parent element is displaying as 0px
Note: I am looking for a solution without using any scripts
Expected Outcome:
https://i.sstatic.net/9jxPQ.png
Current Outcome:
https://i.sstatic.net/Z0gTl.png
HTML Code:
<div class="parent">
<div class="child" style="top:20px;">Hello</div>
<div class="child" style="top:40px;">Some content</div>
<div class="child" style="top:60px;">Some more content</div>
</div>
CSS Styles:
.parent{position:relative;background:green;height:100%;border:1px solid #000000;width:250px;}
.child{position:absolute;}