当前位置: 首页 > news >正文

上下固定中间自适应布局

实现上下固定中间自适应布局

1.通过position:absolute实现

定义如下结构

<body>

<div class="container">

<div class="top"></div>

<div class="center"></div>

<div class="bottom"></div>

</div>

</body>

style实现如下:

<style>body,html {width: 100%;height: 100%;background-color: yellow;margin: 0;padding: 0;}.container {height: 100%;}.top,.bottom {width: 100%;height: 100px;background-color: red;}.bottom {background-color: green;}.center {position: absolute;width: 100%;/* height: 100%; *//* margin-bottom: 100px; */top: 100px;bottom: 100px;background-color: aqua;}</style>

2.通过flex布局实现,父布局高度100%,display:flex;flex-direction: column;设置纵向排列,中间设置flex:1;具体实现如下:

<style>body,html {width: 100%;height: 100%;background-color: yellow;margin: 0;padding: 0;}.container {height: 100%;/* display: flex;flex-direction: column;width: 100%; */}.top,.bottom {width: 100%;height: 100px;background-color: red;}.bottom {background-color: green;}.center {position: relative;width: 100%;/* flex: 1; */height: 100%;/* margin-bottom: 100px; *//* top: 100px; */background-color: aqua;}</style>

http://www.lryc.cn/news/296452.html

相关文章:

  • 3分钟部署完成Docker Registry及可视化管理工具Docker-UI
  • 【npm】修改npm全局安装包的位置路径
  • 数据库切片大对决:ShardingSphere与Mycat技术解析
  • macbook电脑如何永久删除app软件?
  • 安卓——计算器应用(Java)
  • 【笔记】Helm-5 Chart模板指南-8 命名模板
  • Github 2024-02-08 开源项目日报 Top9
  • c语言贪食蛇游戏
  • 国际物流数字化运输方式选择指南 | 箱讯科技
  • FPS游戏框架漫谈第二十天
  • ChatGPT高效提问—prompt常见用法(续篇四)
  • 【蓝桥杯单片机记录】IO基础与LED控制
  • java 回答问题
  • 彻底学会系列:一、机器学习之线性回归(一)
  • FPGA:我的零基础学习路线(2022秋招已上岸)持续更新中~
  • 阿里云游戏服务器多少钱一个月?
  • Win32 SDK Gui编程系列之--ListView自绘OwnerDraw(续)
  • Android 应用添加系统签名权限的几种方式实现介绍
  • 麒麟V10+飞腾处理器源码编译qt
  • MacOS 查AirPods 电量技巧:可实现低电量提醒、自动弹窗
  • python介绍,安装Cpython解释器,IDE工具pycharm的使用
  • 服务器安装Docker (centOS)
  • 解析spritf和sscanf与模拟常用字符串函数strchr,strtok(二)
  • 备战蓝桥杯---搜索(进阶4)
  • 51单片机基础(C语言):定时器时钟
  • 单片机无线发射的原理剖析
  • Redis的过期键的删除策略
  • 放假--寒假自学版 day1(补2.5)
  • LLM(5) | Encoder 和 Decoder 架构
  • CV | Medical-SAM-Adapter论文详解及项目实现