繁体   English   中英

Bootstrap,如何使容器流体的高度为 100%

[英]Bootstrap,How to make a container-fluid have a height of 100%

我有一个包含在 div 中的引导容器流体,现在我希望容器流体的高度为 100%,无论它的内容如何,但它似乎只占用它的高度下面的内容是我的代码

Html
<div class="wrap">
  <div class="container-fluid h-100 test">this is container-fluid
  <div>hello my brother</div>
  </div>

</div>

我的 css

html,
body {
  height: 100%;
}

.wrap {
  min-height: 100%;
  height: auto;
  margin: 0 auto -60px;
  padding: 0 0 60px;
  background: blue;

}


.test {
  height: 100%;
  background-color: yellow;
  border: 1px solid red;
  text-align:center;
}

.footer {
  height: 60px;
  background-color: #f5f5f5;
  border-top: 1px solid #ddd;
  padding-top: 20px;
}

现在我希望黄色 div 占据 100% 的高度,但它没有按预期工作.. 这是我的小提琴

你给wrap a height:auto只是删除那个height:auto意味着它将保持它自己的高度给它的孩子,如果他们是更多的孩子,那么它会增加它自己的高度。只需删除它并添加height:100%

 html, body { height: 100%; }.wrap { height: 100%; margin: 0 auto -60px; padding: 0 0 60px; background: blue; }.test { height: 100%; background-color: yellow; border: 1px solid red; text-align:center; }.footer { height: 60px; background-color: #f5f5f5; border-top: 1px solid #ddd; padding-top: 20px; }
 <:DOCTYPE HTML> <html> <head> <title>Welcome </title> <link rel="stylesheet" href="https.//maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> </head> <body> <div class="wrap"> <div class="container-fluid h-100 test">this is container-fluid <div>hello my brother</div> </div> </div> </body> <footer class="footer"> <div class="container"> <p class="pull-left">my site</p> <p class="pull-right">2019</p> </div> </footer> </html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM