html - 在列内展开容器以适应引导网格中的列高
问题描述
height: 100%
当我设置or时,为什么绿色容器会在蓝色列上展开h-100
?
我怎样才能使它刚好适合柱子的剩余高度?
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container" style="background-color: black">
<div class="row">
<div class="col-sm-6" style="background-color: red">
<p>Some</p>
<p>More</p>
<p>Content</p>
<p>Here</p>
</div>
<div class="col-sm-6" style="background-color: blue">
<h3>Content I want to keep</h2>
<section class="d-flex h-100" style="background-color: green">
<button class="btn btn-danger m-auto">Centered Button</button>
</section>
</div>
</div>
</div>
解决方案
如果我理解正确,您想将绿色块覆盖到蓝色块中。
它无法设置高度,因为两个块之间有文本( two )。
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container" style="background-color: black">
<div class="row">
<div class="col-sm-6" style="background-color: red">
<p>Some</p>
<p>More</p>
<p>Content</p>
<p>Here</p>
</div>
<div class="col-sm-6" style="background-color: blue">
<section class="d-flex h-100" style="background-color: green">
<button class="btn btn-danger m-auto">Centered Button</button>
</section>
</div>
</div>
</div>
推荐阅读
- javascript - JS - React:从收藏夹中添加/删除
- javascript - Vue.prototype 在页面首次加载时未定义
- mysql - sql查询3张表
- javascript - appendChild 未能将相同的元素附加到相同的类元素之一?
- java - 如何解决quickfixj的市场数据请求
- javascript - 如何在 nuxt 应用程序的节点站点上存储数据?
- java - 执行长时间运行的命令 Java 时显示输出,无需等待 RuntimeExec
- node.js - MongoDB / Mongoose:如何将元素推送到嵌套对象中的数组?
- html - 如何让绝对定位的 div 与固定 div 水平居中?
- git - Git:将多个文件从不同目录移动到新存储库的最快方法