html - 将按钮放在 div 的底部
问题描述
我正在使用 bootstrap 4.5,但这只是我想要的一个简单示例。
我有一张固定宽度和高度的卡片,我希望内容占据所有剩余空间,而按钮始终位于底部。我怎样才能做到这一点?
<html>
<body>
<div style="width:400px; height:704px; background-color:gray;">
<div class="container" style="width:100%; height:100%;">
Some content
<button>Some Button</button>
</div>
</div>
</body>
</html>
解决方案
尝试类似的东西,
position:absolute将绝对定位父 div 中的元素。
.bttn {
position: absolute;
right: 50%;
bottom: 0;
}
.cont {
position: relative;
}
<html>
<body>
<div style="width:400px; height:154px; background-color:gray;">
<div class="container cont" style="width:100%; height:100%;">
Some content
<button class="bttn">Some Button</button>
</div>
</div>
</body>
</html>
推荐阅读
- cordova - 无法将 Cordova-plugin-file 添加到 Meteor WhatsApp 教程项目
- c++ - C++ - 字符数组输出删除循环错误
- javascript - 如何替换 JavaScript 中的单词?
- wpf - 如何在堆栈面板中水平对齐文本块
- ionic3 - 使用带有离子滑块的 Ionic 3 Side-Menu(如 Slack)
- angular - Angular 6响应后无法遍历属性
- django - Django formset:从formset保存多个表单
- javascript - 如何使用 JavaScript 添加元素的类
- csv - 如何连接到半列分隔的 CSV 文件表单 ms-access
- sql - 有子句中的相关子查询