对于Bootstrap 4,我希望各个部分的高度相同。但我只想放大内容<div class="content">
(而不是页眉和页脚)
section {
background: #ccc;
border: 1px solid #000
}
header {
background: red;
color: #fff
}
footer {
background: blue;
color: #fff
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-3">
<section>
<header>
Title
</header>
<div class="content">
<ul>
<li>
Item 1
</li>
</ul>
</div>
<footer>
Footer
</footer>
</section>
</div>
<div class="col-3">
<section>
<header>
Title
</header>
<div class="content">
<ul>
<li>
Item 1
</li>
<li>
Item 2
</li>
</ul>
</div>
<footer>
Footer
</footer>
</section>
</div>
<div class="col-3">
<section>
<header>
Title
</header>
<div class="content">
<ul>
<li>
Item 1
</li>
<li>
Item 2
</li>
<li>
Item 3
</li>
<li>
Item 4
</li>
</ul>
</div>
<footer>
Footer
</footer>
</section>
</div>
</div>
你能帮助我吗?
最佳答案
section {
background: #ccc;
border: 1px solid #000;
height: 100%;
display: flex !important;
flex-direction: column;
align-content: space-between;
}
header {
background: red;
color: #fff
}
footer {
background: blue;
color: #fff
}
.content {
flex: 1 0 auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-3">
<section>
<header>
Title
</header>
<div class="content">
<ul>
<li>
Item 1
</li>
</ul>
</div>
<footer>
Footer
</footer>
</section>
</div>
<div class="col-3">
<section>
<header>
Title
</header>
<div class="content">
<ul>
<li>
Item 1
</li>
<li>
Item 2
</li>
</ul>
</div>
<footer>
Footer
</footer>
</section>
</div>
<div class="col-3">
<section>
<header>
Title
</header>
<div class="content">
<ul>
<li>
Item 1
</li>
<li>
Item 2
</li>
<li>
Item 3
</li>
<li>
Item 4
</li>
</ul>
</div>
<footer>
Footer
</footer>
</section>
</div>
</div>