【发布时间】:2018-02-26 02:31:30
【问题描述】:
如何才能完成下面的这个css问题?
这是指屏幕有足够的空间来保持元素可见。
但是一旦窗口缩小并且没有足够的空间使它们以原始大小保持可见,顶部和底部元素会粘在原始大小的垂直边上,并且只有中间元素会缩小。
我陷入了这种状态。乍一看几乎接近答案,但实际上并非如此......
http://embed.plnkr.co/AJXYCGEVzMPt1My0xehA/
堆栈sn-p
/* Styles go here */
.wrapper {
height: 100vh;
}
.top {
width: 40%;
height: 50px;
background-color: green;
}
.middle {
width: 90%;
height: 300px;
background-color: blue;
margin-top: 30px;
margin-bottom: 30px;
}
.bottom {
width: 20%;
height: 50px;
background-color: red;
}
<link data-require="bootstrap@4.0.5" data-semver="4.0.5" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" />
<div class="wrapper d-flex flex-column align-items-center justify-content-center">
<div class="top col-auto">Top Element</div>
<div class="middle col-auto">Middle Element</div>
<div class="bottom col-auto">Bottom Element</div>
</div>
【问题讨论】:
标签: html twitter-bootstrap css flexbox