-1
我有一个包含子div的父级div。我希望父div自动调整大小,以便孩子总是在父母的边界内。现在由于相对定位,子div的底部延伸到父代的底部。我如何获得父级调整大小?如何获得父级div来调整其高度
#parentDiv {
margin: 40px 0 0 40px;
background-color: #eae;
width: 1500px;
height: auto;
}
#childDiv {
position: relative;
max-width: 400px;
min-height: 200px;
background-color: #B9D7D9;
top: 20px;
left: 20px;
}
<div id="parentDiv">
<div id="childDiv">
</div>
</div>