工作,我有這樣的代碼顯示absolute div
到relative div
。CSS高度自動不相對DIV
HTML:
<section>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="relative">
<div class="absolute">Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element.</div>
</div>
</div>
<div class="col-md-12">
normal text added
</div>
</div>
</div>
</section>
CSS:
.relative {
position: relative;
height:auto;
background-color:#e1e1e1;
}
.absolute {
position: absolute;
bottom: 0;
left: 0;
background-color: white;
width: auto;
background-color:#f5f5f5;
margin:0 15px;
}
在現實中,當我設置爲height:auto
這relative div
div
沒有顯示。如果我設置任何height
值,即:height:150px;
相對div
它的工作原理和顯示正確。我該如何解決這個問題?
演示here
替換代碼.... .absolute { 的位置是:絕對的; bottom:0; left:0; background-color:white; 寬度:100%; background-color:#f5f5f5; margin:0 15px; 身高:100%; } –