html - 在 Bootstrap 4 中将项目拉伸到屏幕的整个长度
问题描述
如何将标记为红色的“col”元素拉伸到整个屏幕长度?
我试过这个:
class="... w-100"
和这个:
<div class="..." style="height:100vh;">
我的 col 元素如下所示:
<div class="col-12 col-lg-3 col-xl-2 px-lg-0 border-right-lg border-gray-300 bg-dark text-white w-100" style="height:100vh;">
[...]
</div>
解决方案
如果您希望您的 div 的高度等于视口的高度,请vh-100
在其上放置类。或者申请min-height: 100vh
它。
如果您希望它具有整个屏幕宽度,请使用此标记:.container-fluid > .row > .col
.
这是一个总是推到屏幕底部的布局(根据您的图片):
/* test */
.left-col {
background: indigo;
}
.footer {
/* this is not needed it if you want content to set its size
* but mine is empty
*/
min-height: 150px;
border: 1px solid red;
}
.full-layout {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.full-layout .row {
flex-grow: 1;
}
.full-layout .row:last-child {
flex-grow: 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid full-layout">
<div class="row">
<div class="col-sm-3 left-col"></div>
</div>
<div class="row">
<div class="col vw-100 footer"></div>
</div>
</div>
推荐阅读
- spring-integration - 如何在 Spring Integration Rest 服务调用中的 Http.outboundGateway 中添加自定义标头?
- php - PHP - 使用爆炸增加文本文件中的多个值
- excel - Survey Monkey 的 Excel 数据清理检查所有适用的
- android - 我对 Datepicker 上下文有问题(android studio)
- c# - 如何使用 C# Core 3.1 在 Bot Framework v4 中拦截消息以进行日志记录
- constraints - scipy 优化 trust-constr 违反线性约束
- javascript - Jest/react-testing-library:单击按钮未更新测试中的值
- visual-studio-code - 在 Visual Studio 代码中调试 C++ 时,我的代码不会在断点处停止
- c# - 从一个文件夹中获取 xslx 和 xls 文件并将其复制到另一个文件夹中
- openshift - 我可以在 Openshift 主节点或 Infra 节点上运行用户 pod