【问题标题】:Container not going 100% height容器没有达到 100% 的高度
【发布时间】:2017-05-11 05:54:13
【问题描述】:

我将容器设置为 display: flex 与引导程序 4 类 d-flex 但它不会达到 100% 的高度。我希望列的高度为 100%,这样我就可以将内容垂直居中。

这里是代码sn-p:

#recruitment-header {
  background-image: url(http://cdn01.androidauthority.net/wp-content/uploads/2015/11/00-best-backgrounds-and-wallpaper-apps-for-android.jpg);
  background-size: cover;
  min-height: 400px;
  background-repeat: no-repeat;
  background-position: center;
  color: #fff;
}
#recruitment-header .container, #recruitment-header .row {
  height: 100%;
}
#recruitment-header .slogan1 {
  font-size: 46px;
}
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>


<div id="recruitment-header" class="d-flex">
    <div class="container d-flex">
        <div class="row d-flex">
            <div class="col-12 d-flex flex-column justify-content-center">
                <div class="slogan1">message one</div>
                <div class="slogan2">message two</div>
            </div>
        </div>
    </div>
</div>

为什么它没有达到 100% 的高度?

【问题讨论】:

标签: html twitter-bootstrap css flexbox


【解决方案1】:

尝试添加以下内容

#recruitment-header .container, #recruitment-header .row {
  flex-direction: column;
  flex: 1;
}

【讨论】:

  • 同时从该列表中删除 height: 100%
猜你喜欢
  • 2016-07-13
  • 2013-08-03
  • 1970-01-01
  • 1970-01-01
  • 2017-05-11
  • 1970-01-01
  • 2014-03-09
  • 2018-04-19
  • 1970-01-01
相关资源
最近更新 更多