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>
相关推荐
小小19928 小时前
idea 配置less转化为css
前端·css·less
hhb_6188 小时前
Less嵌套避坑:优先级冲突实战解析
前端·css·less
AI视觉网奇12 小时前
three教学 3d资产拼接源代码
前端·css·css3
用户0595401744614 小时前
RAG 记忆层踩坑实录:用户偏好凭空消失,我排查了 4 小时,最后用 LangChain + Chroma 搭了套自动化回归测试
前端·css
何何____15 小时前
svg基本图形绘制介绍
前端·css
jnene1 天前
html 时间、价格筛选样式处理
前端·css·html
用户059540174462 天前
Redis 缓存过期不一致踩坑实录:一个 bug 让我排查了 3 小时,最终用 Pytest 自动化堵上漏洞
前端·css
神明不懂浪漫2 天前
【第三章】CSS(一)——基础选择器、CSS的属性
前端·css·html·css3
用户059540174462 天前
localStorage清除策略踩坑实录:一个过期的token让我排查了3小时
前端·css
#麻辣小龙虾#2 天前
js实现视频播放画中画模式
javascript·css·音视频