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>
相关推荐
卡尔特斯14 小时前
CSS 特殊符号 / 英文导致换行问题速查表
css
Komorebi゛14 小时前
【CSS】斜角流光样式
前端·css
Irene199114 小时前
CSS 废弃属性分类总结
前端·css
San30.21 小时前
告别全局污染:深入解析现代前端的模块化 CSS 演进之路
前端·css·vue.js·react.js
23级二本计科21 小时前
前端 HTML + CSS + JavaScript
前端·css·html
xuedaobian1 天前
Markdown 宽表格突破容器边界滚动方案
前端·css
AI前端老薛1 天前
CSS实现动画的几种方式
前端·css
San301 天前
告别全局污染:深入解析现代前端的模块化 CSS 演进之路
css·vue.js·react.js
程序员小李白1 天前
定位.轮播图详细解析
前端·css·html
码客前端1 天前
理解 Flex 布局中的 flex:1 与 min-width: 0 问题
前端·css·css3