html - Bootstrap 4:修复容器底部的内容
问题描述
我有一个围绕 a 的应用程序<div class="container">
,其中有一个编辑器和一些按钮,我总是希望在底部显示它们,如下所示:
<div class="container>
// some content....
// this should be shown always at the bottom!
<div id="bottom" class="submit-form">
<div id="editor"></div>
<div class="btn btn-grp" ></div>
</div>
我尝试将 html、body 和 container 的 min-height 和 height 属性更改为 100%,并在此规则中添加了重要内容,但这不会使我的 div 容器向下拉伸。当我使用“fixed-bottom”引导类时,#bottom div 在容器边界上水平延伸,这使得布局非常难看。
有什么建议么?:)
解决方案
用另一个容器包装您的“提交表单”或col-*
用于定位。
例如:
<div class="container">
<!-- some content.... -->
<!-- this should be shown always at the bottom! -->
<div id="bottom" class="container fixed-bottom submit-form">
<div id="editor"></div>
<div class="btn btn-grp" ></div>
</div>
</div>
按类操作您的 div 大小col-*
(引导网格包含 12 列,因此下面的 div 将覆盖 4 列屏幕大小):
<div class="container">
<!-- some content.... -->
<!-- this should be shown always at the bottom! -->
<div id="bottom" class="col-4 fixed-bottom submit-form">
<div id="editor"></div>
<div class="btn btn-grp" ></div>
</div>
</div>
之后,此表单将与屏幕左侧对齐。
使用 d-flex 定位引导列:
<div class="container">
<!-- some content.... -->
<!-- this should be shown always at the bottom! -->
<div class="d-flex justify-content-center fixed-bottom">
<div id="bottom" class="col-4 submit-form">
<div id="editor"></div>
<div class="btn btn-grp" ></div>
</div>
</div>
</div>
如果您想创建响应式网站,您应该阅读有关引导网格系统和使用等的内容col-md-*
,col-sm-*
而不是col-*
:
推荐阅读
- android - 在 Windows 中安装颤振时遇到问题。我的 sdp 路径不存在
- android - 适用于 Android 上的索尼 X3000 的相机远程 SDK。流式传输 4k 视频?
- c# - 是否可以使用 c#.net 以编程方式检查某个 .com 域是否存在?
- html - img溢出的body元素 - 出现滚动条
- python - 如何将熊猫数据框(系列)转换为字典
- python - 如何将编码错误的字节字符串转换为普通字符串?
- javascript - 将数据传递给 Angular Guard CanActivateChild
- flutter - Flutter Firestore - 检索仅属于特定 id 集的文档快照并在屏幕上显示该数据
- swiftui - SwiftUI ZStack:将一些后代对齐到底部,一些到顶部
- node.js - 使用 Docker (Dockerfile) 的 Mongo Atlas 身份验证错误