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>
相关推荐
blns_yxl4 小时前
正则驱动实时表单验证(HTML+CSS+JS+正则)
javascript·css·html
思码梁田1 天前
CSS cursor 属性全解析:从“小手“开始,玩转鼠标光标
前端·css·计算机外设·cursor·pointer
黑土豆1 天前
CSS 新特性:Container Queries 到底能解决什么痛点?
前端·css
思码梁田1 天前
CSS vertical-align 属性详解:表格与图文对齐的实用指南
前端·css·vertical-align
用户059540174462 天前
把记忆存储的回归测试从手工换成 Playwright + GitHub Actions,线上缺陷降低 80%
前端·css
cll_8692418912 天前
一个好看的Wordpress博客文字css样式
前端·css·ui
三翼鸟数字化技术团队2 天前
一种前端大屏适配方案
前端·css
muddjsv2 天前
CSS核心语法精讲:彻底吃透规则结构、选择器与声明规范
前端·css
触底反弹3 天前
一文搞懂 Tailwind CSS 弹性布局:从原理到实战
前端·css·html
小白巨白3 天前
玫瑰花园管理系统:AI识病+3D可视化,一套面向中小型玫瑰种植园的数字化管理工具
css·人工智能·计算机视觉·html5