html - CSS 填充页面的 Div 高度

标签 html css

<分区>

我需要 div 底部来填充 PAGE 的剩余高度,而不是父 div

body, html {
  margin: 0px;
}

.top {
  background-color: green;
  width: 100px;
  height: 50px;
}

.bottom {
  background-color: red;
  width: 100px;
  height: 100%;
}
<div class="top"></div>
<div class="bottom"></div>

最佳答案

您可以使用 calcvh 来计算页面的 100% 高度减去 top50px分区。

看看这个片段:

body, html {
  margin: 0px;
}

.top {
  background-color: green;
  width: 100px;
  height: 50px;
}

.bottom {
  background-color: red;
  width: 100px;
  height: calc(100vh - 50px);
}
<div class="top"></div>
<div class="bottom"></div>

关于html - CSS 填充页面的 Div 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49510786/

上一篇:html - CSS步动画摇动图像

下一篇:html - 如何在侧边栏的中心垂直和水平移动此导航栏

相关文章:

jquery - 使用 jquery 和 css 的特殊进度条

javascript - 在 JS 代码中添加弹出框的 html 内容的好习惯是什么?

html - 包裹元素上的 CSS 容器宽度

javascript - 出现覆盖时防止背景滚动

css - 包含 div 的 Internet Explorer 7 溢出

jquery - Jssor Slider CSS 分离?

python - 使用 Flask/Jinja2 宏设置事件导航元素的样式

javascript - 从 phantomjs 打印 pdf 时出现空格

javascript - 将一个 div 的元素发送到另一个 div

屏幕分辨率/大小更改时 HTML 页面不相似