CSS:上面固定高度、下面填充满,上面消失,下面仍然填充满

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  html, body {
  height: 100%;
  margin: 0;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100%; /* 使用最小高度来确保占据整个屏幕 */
}

.top {
  height: 100px;
  background-color: lightgray;
}

.bottom {
  flex-grow: 1;
  background-color: lightblue;
}
</style>
<body>
  <div class="container">
    <div class="top">上</div>
    <div class="bottom">下</div>
  </div>
</body>
</html>
相关推荐
丨我是张先生丨20 小时前
日语单词 Web Page
前端·css·css3
吃西瓜不吐籽_1 天前
2026 届前端校招冲刺:2 万字高频面试题库(含详解、追问与评分标准)
前端·javascript·css·typescript·前端框架·es6
Csvn2 天前
CSS :has() 选择器实战:没有它之前我们写了多少冗余 JS
前端·css
用户059540174463 天前
大模型长上下文遗忘排查实录:用 Playwright 自动化测试,揪出了 90% 的存储序列化 bug
前端·css
天蓝色的鱼鱼4 天前
关于 CSS 你可能不知道的属性,但关键时刻很有用
前端·css
用户059540174464 天前
向量库静默丢数据踩坑实录:Playwright 端到端测试让我排查了72小时
前端·css
ZhengEnCi5 天前
Q06-导航按钮高级拟态玻璃效果构建完全指南
前端·css
用户059540174465 天前
Redis持久化踩坑实录:这个数据丢失Bug让我排查了6小时
前端·css
用户059540174466 天前
Redis记忆存储故障恢复测试踩坑实录:手动测试让我漏掉了2个一致性Bug
前端·css
用户059540174466 天前
用了3年Mock,才发现Redis记忆存储的测试一直漏掉了60%的边界场景
前端·css