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>
相关推荐
切糕师学AI7 小时前
Less Mixin 详解:让 CSS 像函数一样复用
前端·css·less mixin
打呵欠的猫1 天前
我用 AI 把 CSS 从"每人一种风格"统一成了设计系统 Token,再也不吵"用什么颜色"了
css·ai编程
GuWenyue1 天前
z-index 写到 9999 还是被盖住:把层叠上下文的 6 个反例全复现了一遍
前端·css·浏览器
qinqinzqq1 天前
CSS Grid 命名区域布局:组件 Header / Content / Sider 两栏布局实践
前端·css
Mh2 天前
基于踩过的坑,浅聊一下vh、svh、lvh、dvh
前端·css·设计模式
金八梭8 天前
格斗对决v4.5
前端·css·自动化·html·css3
CappuccinoRose10 天前
前端开发交互体系 - 汇总篇
开发语言·前端·javascript·css·html·交互
inksci12 天前
用飞帆做了个小网页
前端·javascript·css·html
星云_byto12 天前
CSS面试题
前端·css
科研邪修法13 天前
PDF新增页面文字与文本批注怎么区分?以双版本培训讲义为例
前端·css·pdf