I've got a div whose height is determined by an encolsed div. The issue with that is, when i add some extra margin on the top the encolsing div resizes properly. When i add the margin on the bottom it seems like only the enclosed div box model is affected and the enclosing div is not.
HTML
<div style="height:100px;background-color:#adadbb">
IRRELEVANT THINGS HERE
</div>
<div class="dynamicDiv">
<span> title</span>
<div class="card">
Content here
</div>
</div>
<div style="height:100px;background-color:#adadbb">
IRRELEVANT THINGS HERE VOL 2
</div>
CSS
.dynamicDiv{
background-color:yellow;
}
.card{
height:15vh; //an example of the height for this card. could be anything.
margin-top:10px;
margin-bottom:10px;
}
It appears that this has something to do with the <span> title</span>
element as if i add one on the bottom thigns work as i would expect them to ( unless the span is empty in which case things render as if the span isnt there ).
I dont very well understand why this happens so if its something obvious that has to do with the box model please let me know. Thanks a lot.
Fiddle here :
https://jsfiddle.net/d88yr4yw/
P.S: What im trying to achieve is have a div that is always as high as the enclosed div height + a margin top and bottom + whatever other elements might be in there. I'd rather i didnt have to hardcode any heights if not impossible to work around this otherwise though.