-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>