css - 基于父级的 div 动态最大高度

标签 css height

假设我有以下内容:

.wrap { height:400px; }
.header { height:100px; }
.footer { height:100px; }

<div class="wrap">
  <div class="header"></div>
  <div class="middle_row"></div>
  <div class="footer"></div>
</div>

是否有任何 CSS 解决方案可以将 .middle_row 动态拉伸(stretch)到 200px?

最佳答案

是的,尝试 Flexbox

.wrap {
  display: flex;
  height: 400px;
  flex-direction: column;
}

.header, .footer {
  flex: 0 0 100px;
  background: lightblue;
}

.middle_row {
  flex: 1;
  background: lightgreen;
}
<div class="wrap">
  <div class="header"></div>
  <div class="middle_row"></div>
  <div class="footer"></div>
</div>

关于css - 基于父级的 div 动态最大高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35606223/

相关文章:

php - 验证码问题

css - SAS中的框架集和框架改变高度

css - 将伸缩容器高度设置为等于最小伸缩元素的高度

css - 如何使用Div相对高度100%?

html - 关于CSS高度的问题

jquery - CSS height 和 inline height 属性不服从我

jquery - 如何限制html中的默认工具提示宽度

css - AngularJS 单页应用 : google maps reloading weirdness

css - 如何启用模式内的内容滚动?

html - input type=range 在 ie11 中没有样式