我有一个2列布局,第一列是垂直导航,右列用于内容。
我希望第一列至少占据视口大小的100%,但如果主内容大于视口,则需要增加其高度。
如何使第一列(黄色)与第二列相同高度?
html,body {
height: 100%;
}
#yellow {
height: 100%;
background: yellow;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid h-100">
<div class="row h-100">
<div class="col-3 h-100" id="yellow">
XXXX
</div>
<div class="col-9 h-100">
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
Content goes here<br>
</div>
</div>
</div>
min-height
而不是height
,这样第一列将至少达到100% - 最小值100%。 - zgood