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>
相关推荐
EchoEcho4 小时前
记录overflow:hidden和scrollIntoView导致的页面问题
前端·css
im_AMBER4 小时前
告别“玄学”UI:从“删代码碰运气”到“控制 BFC 结界”
前端·css
芳草萋萋鹦鹉洲哦5 小时前
【Tailwind】动画解读:Tailwind CSS Animation Examples
前端·css
Mr Xu_21 小时前
前端开发中CSS代码的优化与复用:从公共样式提取到CSS变量的最佳实践
前端·css
Lee川1 天前
CSS盒模型实战:用代码透视 `border-box`与 `content-box`的天壤之别
css
哈里谢顿1 天前
CSS 入门完全指南:从零构建你的第一个样式表
css
. . . . .1 天前
CSS 编写与管理范式 - Tailwind和CSS-in-JS
css
RFCEO2 天前
前端编程 课程十六、:CSS 盒子模型
css·前端基础课程·css盒子模型·css盒子模型的组成·精准控制元素的大小和位置·css布局的基石·内边距(padding)
夏幻灵2 天前
CSS三大特性:层叠、继承与优先级解析
前端·css
会编程的土豆3 天前
新手前端小细节
前端·css·html·项目