javascript - 调整Bootstrap 网站上的 -height 到 window-height
问题描述
假设我有一个使用Bootstrap 4制作的简单网站,其中包含页眉、导航栏、内容区域和页脚。
我的演示网站可以在 JSFiddle 上找到并实时编辑:https
://jsfiddle.net/26zda5xv/2/
请在下面找到该网站的屏幕截图:
我希望<div class="container">
至少填写整个页面/窗口高度。( min-height?
)
这应该通过扩展<div id="content">
.
当然,该解决方案应该自动处理各种屏幕分辨率/设备。
如何根据 JSFiddle 正确执行此操作?
Bootstrap 4 中是否有针对此任务的内置解决方案?
谢谢!
解决方案
要解决这个问题,我们需要 2 个步骤:
将
d-flex flex-column min-vh-100
类添加到容器中。将
flex-grow-1
类添加到内容 div
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<body class="bg-secondary">
<div class="container bg-white shadow border border-dark d-flex flex-column min-vh-100">
<img src="http://www.apexcartage.com/wp-content/uploads/2014/05/placeholder-blue.png" class="img-fluid" alt="Responsive image">
<nav class="navbar navbar-dark bg-dark">
<a class="navbar-brand" href="#">Navbar</a>
</nav>
<div id="content" class="my-3 flex-grow-1">
<p class="h3">Content</p>
</div>
<footer>
<div class="bg-dark text-white mt-4 p-3 border-info" style="border-top: 4px solid">
<h5 class="title">Footer</h5>
</div>
<div class="bg-info p-1"></div>
</footer>
</div>
</body>
推荐阅读
- python - 如何使用 Bokeh 中的下拉菜单在数字之间切换?
- loops - 在循环中创建按钮并将数组元素设置为标题
- javascript - 调用 firebase.messaging.getToken() 时出现“请求缺少身份验证凭据”错误
- reactjs - TypeErro:无法读取 null 的属性“数据”
- git - Jenkins 中的条件代理
- java - 为什么 javax.lang.model.element.Name 存在?
- csv - 木薯跳过或忽略列
- animated-gif - 在 Amstrad E3 上显示一个带有 Linux 2.6.16 的动画 gif ..?
- machine-learning - 检查输入时出错:预期 conv2d_1_input 的形状为 (1, 28, 28) 但得到的数组的形状为 (28, 28, 1)
- r - 在数据框的每一行中应用条件函数