javascript - 如何拉伸一个块的高度?
问题描述
父单元.wrapper
的高度为 100%。子块的高度.info
未定义,可能不同。如何.wrp
为父块的整个剩余高度拉伸子块.wrapper
?
Аssociation: https://ru.stackoverflow.com
还有其他选择吗?
body,
html {
height: 100%;
margin: 0;
padding: 0;
}
div {
margin: 0;
padding: 0;
}
.wrapper {
display: block;
overflow: hidden;
height: 100%;
width: 100%;
background-color: silver;
}
.wrp {
display: block;
width: 100%;
height: 100%;
background-color: chocolate;
}
.info {
display: block;
width: 100%;
background-color: blue;
}
<div class="wrapper">
<div class="wrp"></div>
<div class="info">Did you see the virgin on the rock <br>in a white robe over the waves<br>When, raging in the stormy darkness, <br>the sea Played with the shores,<br>When a ray of lightning lit up<br>Her hourly brilliance with scarlet <br>and the wind beat and flew<br>With her flying veil?</div>
</div>
解决方案
你不需要 jquery,只需要改变 layer .wrapper display:flex 而不是 display:block
.wrapper {
display: flex;
overflow: hidden;
height: 100%;
width: 100%;
background-color: silver;
}
https://jsfiddle.net/MAXXALANDER/tm493n1w/2/
那是你需要的吗?
推荐阅读
- vue.js - 无法将 Axios 默认标头添加到 VueJS 应用程序
- r - 如何在 r 中有两个向量的两个列表上运行循环?
- java - 是否可以在 PC 的 IDE Eclipse 和 Netbeans 中使用 Apache Tomcat 服务器?
- excel - 使用已由 COUNTIF 函数识别的基于 AVERAGEIF、MAXIF 等的单元格
- regex - 在正则表达式中匹配一个单词作为一个组
- python - 本守则有任何错误吗?如果是让我知道?
- wordpress - WordPress 和 SHA256 密码
- java - Java/Kotlin for Android - 硬编码对象或电子表格读取
- swift - 具有 4 个文本字段的自定义单元格
- reactjs - 使用 Chai\Mocha 设置进行单元测试时,如何让 JSDOM 与 typescript 一起使用?