使用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>
你能帮助我吗?
答案 0 :(得分:1)
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;
}
&#13;
<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>
&#13;
答案 1 :(得分:0)
这样的东西?
.content {
min-height: 150px;
height: 150px;
}
section {
background: #ccc;
border: 1px solid #000
}
header {
background: red;
color: #fff
}
footer {
background: blue;
color: #fff
}
.content {
min-height: 150px;
height: 150px;
}
&#13;
<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>
&#13;