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>
相关推荐
feixing_fx11 小时前
CSS Grid 入门:二维布局时代的降维打击
前端·css·前端框架·css3
2603_9658966211 小时前
CSS BEM 命名规范|组件化样式分层权威指南
前端·javascript·css
进击的明明11 小时前
前端开发中的 BEM 国际命名规范:让 CSS 不再"打架"
前端·css·html
燕落南枝13 小时前
CSS 分组选择器与链接伪类选择器详解
前端·css
溪语流沙18 小时前
【每天一个CSS | Day33】聚焦即弹出的命令面板
前端·css·html5·组件·每日一练
燕落南枝18 小时前
CSS 用户行为伪类::hover 与 :focus 详解
前端·css
钱栈up1 天前
前端改了三页、后端也动了,用户说「完全没变化」——我在 116 库上找到的三个真凶
css·数据库
燕落南枝2 天前
CSS 字体样式:颜色、字体族、倾斜、加粗与装饰
前端·css
狮子座的男孩2 天前
html+css基础:24、2D变换(位移/缩放/旋转/扭曲(了解)/多重变换/变换原点)
前端·css·经验分享·html·2d位移·原点变换·缩放/旋转/扭曲
子兮曰2 天前
CSS 复现 23 种设计风格:从拟物到液态玻璃的成本阶梯与兜底写法【实战】
前端·css·视觉设计