一,上固定,下自适应

1,代码

<div class="all">
<div class="top">111</div>
<div class="center">222</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
} .top {
width: 100%;
height: 100px;
background-color: #1ab394;
} .center {
width: 100%;
flex: 1;
background-color: #1c84c6;
}
</style>

2,图例

二,下固定,上自适应

1,代码

<div class="all">
<div class="top">111</div>
<div class="center">222</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
} .top {
width: 100%;
flex: 1;
background-color: #1c84c6;
} .center {
width: 100%;
height: 100px;
background-color: #1ab394;
}
</style>

2,图例

三,上下固定,中间自适应

1,代码

<div class="all">
<div class="top">111</div>
<div class="center">222</div>
<div class="bottom">333</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
} .top {
width: 100%;
height: 100px;
background-color: #1ab394;
} .center {
width: 100%;
flex: 1;
background-color: #1c84c6;
} .bottom{
width: 100%;
height: 100px;
background-color: #13ce66;
} </style>

2,图例

四,左固定,右自适应

1,代码

1.1,float布局

<div class="all">
<div class="left">111</div>
<div class="right">222</div>
</div> <style>
.all {
width: 100%;
height: 100%;
} .left {
width: 320px;
height: 100%;
float: left;
background: #409EFF;
} .right {
width: 100%;
height: 100%;
background: #008489;
}
</style>

1.2,flex布局

<div class="all">
<div class="left">111</div>
<div class="right">222</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: flex;
} .left {
width: 320px;
height: 100%;
flex:none;
background: #409EFF;
} .right {
width: 100%;
height: 100%;
flex:1;
background: #008489;
}
</style>

1.3,table布局

<div class="all">
<div class="left">111</div>
<div class="right">222</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: table;
} .left {
width: 320px;
height: 100%;
display:table-cell;
background: #409EFF;
} .right {
height: 100%;
display:table-cell;
background: #008489;
}
</style>

1.4,calc布局

<div class="all">
<div class="left">111</div>
<div class="right">222</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: table;
} .left {
width: 320px;
height: 100%;
float:left;
background: #409EFF;
} .right {
height: 100%;
float:right;
width:calc(100% - 320px);
background: #008489;
}
</style>

1.5,margin-left布局

<div class="all">
<div class="left">111</div>
<div class="right">222</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: table;
} .left {
width: 320px;
height: 100%;
float:left;
background: #409EFF;
} .right {
height: 100%;
width:auto;
margin-left:320px;
background: #008489;
}
</style>

2,图例

五,综合

1,仿网站布局1

先左固定,右自适应;再上下固定,中自适应

<div class="all">
<div class="left">111</div>
<div class="right">
<div class="right-top">222</div>
<div class="right-center">333</div>
<div class="right-bottom">444</div>
</div>
</div> <style>
.all {
width: 100%;
height: 100%;
} .left {
width: 320px;
height: 100%;
float: left;
background: #409EFF;
} .right {
height: 100%;
width: auto;
margin-left: 320px;
background: #008489; display: flex;
flex-direction: column;
} .right-top {
width: 100%;
height: 100px;
background-color: #1ab394;
} .right-center {
width: 100%;
flex: 1;
background-color: #1c84c6;
} .right-bottom {
width: 100%;
height: 100px;
background-color: #13ce66;
}
</style>

2,仿网站布局2

先上固定,下自适应;再左固定,右自适应

<div class="all">
<div class="top">111</div>
<div class="center">
<div class="left">222</div>
<div class="right">333</div>
</div>
<div class="bottom">444</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
} .top {
width: 100%;
height: 100px;
background-color: #1ab394;
} .center {
width: 100%;
flex: 1;
background-color: #1c84c6;
} .bottom {
width: 100%;
height: 100px;
background-color: #13ce66;
} .left {
width: 320px;
height: 100%;
float: left;
background: #409EFF;
} .right {
height: 100%;
width: auto;
margin-left: 320px;
background: #008489;
}
</style>

如图所示

3,仿XShell页面布局

先上固定,下自适应;再左固定,右自适应;最后左上自适应,左下固定

<div class="all">
<div class="top">111</div>
<div class="center">
<div class="left">
<div class="left-top">222</div>
<div class="left-bottom">333</div>
</div>
<div class="right">444</div>
</div>
<div class="bottom">555</div>
</div> <style>
.all {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
} .top {
width: 100%;
height: 100px;
background-color: #1ab394;
} .center {
width: 100%;
flex: 1;
background-color: #1c84c6;
} .bottom {
width: 100%;
height: 100px;
background-color: #13ce66;
} .left {
width: 320px;
height: 100%;
float: left;
background: #409EFF; display: flex;
flex-direction: column;
} .right {
height: 100%;
width: auto;
margin-left: 320px;
background: #008489;
} .left-top {
width: 100%;
flex: 1;
background-color: #1c84c6;
} .left-bottom {
width: 100%;
height: 100px;
background-color: #1ab394;
} </style>

div上固定,下自适应;div左固定,右自适应的更多相关文章

  1. 用于阻止div上的事件和div上的按钮的事件同时触发

    event.stopPropagation()  阻止事件冒泡  用于ie11以上

  2. html同行两个div浮动后下一个div怎么换行的问题

    传送门:https://blog.csdn.net/asdfg6541/article/details/78514535

  3. DIV+CSS布局问题:一个宽度不确定的DIV里面放三个水平对齐的DIV,左右两个DIV宽度固定为150px,中间那个DIV充满剩余的宽度

    一个入门的DIV+CSS布局问题:一个宽度不确定的DIV里面放三个水平对齐的DIV,左右两个DIV宽度固定为150px,中间那个DIV充满剩余的宽度. 说明:代码非真实情况下使用,所以直接简单. 没耐 ...

  4. Django循环创造div后,对各个div操作后触发事件,传递数据(Django九)

    前面我用for循环创建了div,每个div中有各自的数据以及同样的布局 效果图如下:部分代码如下: 现在,我希望在点击每个div里的发表按钮时,能在js里获取{{problem.pro_id}}以及{ ...

  5. Jquery的鼠标移动上去显示div,鼠标离开的时候隐藏div效果

    有时候我们需要这个效果:当鼠标放上去的时候显示一个div,当鼠标移走的时候就将div隐藏了.代码如下,记得引入Jquyer库.(当鼠标移动到id=menu的div上的时候,显示id=list的div, ...

  6. 剑指Offer - 九度1523 - 从上往下打印二叉树

    剑指Offer - 九度1523 - 从上往下打印二叉树2013-12-01 00:35 题目描述: 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 输入: 输入可能包含多个测试样例,输入以E ...

  7. 论气机之"左升右降"

      生命现象源于气机的出入升降运动. “出入废则神机化灭,升降息则气立孤危.故非出入,则无以生长壮老已:非升降,则无以生长化收藏”(<素问·六微旨大论>),升降是气机主要的运动形式之一,是 ...

  8. 上中下三个DIV,高度自适应(上高度固定,下固定,中间自适应)(代码来自X人)

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DivDemo.aspx.c ...

  9. css 两列 左侧列固定 width: 100px; float: left; 右侧列自适应 margin-left:100px; 注意要用在div上的style

    css 两列 左侧列固定 width: 100px; float: left; 右侧列自适应 margin-left:100px; 注意要用在div上的style .con1{ width: 100p ...

  10. xHTML+div布局:三个div,两边div宽度固定,中间div宽度自适应

    xHTML+div经常考题:三个div,两边div宽度固定,中间div宽度自适应. 和大家分享一个实现方式: 1.html代码 <div class="dyleft"> ...

随机推荐

  1. Hibernate Validator 校验注解

    Hibernate Validator 校验注解/** * 认识一些校验注解Hibernate Validator * * @NotNull 值不能为空 * @Null 值必须为空 * @Patter ...

  2. doris wget 地址

    wget https://apache-doris-releases.oss-accelerate.aliyuncs.com/apache-doris-2.0.0-alpha1-bin-x86_64. ...

  3. Linux 内核:设备驱动模型(4)uevent与热插拔

    Linux 内核:设备驱动模型(4)uevent与热插拔 背景 我们简单回顾一下Linux的设备驱动模型(Linux Device Driver Model,LDDM): 1.在<sysfs与k ...

  4. podman+openresty+openssl,https双向认证demo测试

    前言 暂不讨论https原理,单论配置的话: 1. https单项认证 server: server.crt + server.key client: server_ca.crt 2. https双向 ...

  5. HSCSEC CTF 2023

    HSCSEC CTF 2023_misc的部分writeup 有趣的比赛,学到了新姿势orz Ancient-MISC Deduced gossip ☲☵ ☷☵☳ ☶空 ☷☵☳ ☶☱ ☶空 ☷空☱ ☶ ...

  6. MongoDB安装、基础操作和聚合实例详解

    虽然MongoDB这些年很流行,但笔者之前没研究过,现在有需求研究这类NoSQL的数据库,是为了验证其是否可被替换. MongoDB是很轻量的文档数据库,简单测试也懒得专门准备虚拟机环境了,直接在ma ...

  7. 六.黑马程序员-eclipse的使用和快捷键

    1.Eclipse的概述 A: 是一个集成开发工具,专门针对java的 B: Eclipse 免费的 开源 C: MyEclipse 收费的 具体良好的插件扩展功能,针对插件收费2.Eclipse的使 ...

  8. Java-C3P0和Druid连接池的运用

    1.概念 其实就是一个容器(集合),存放数据库连接的容器 当系统初始化好后,容器被创建,容器会申请一些连接对象,当用户来访问数据库时,从容器中获取连接对象,用户访问完之后,会将连接对象归还给容器. 好 ...

  9. 启动数据分析软件SPSS17遭遇的两弹窗解决方案

    问题描述 朋友请我帮她安装 SPSS17 这款软件,我寻思这是啥软件,谷歌一下,发现是一个数据分析工具. 在一系列的下一步.确定后,打开时,第 1 个惊喜弹窗来了: [弹窗内容]应用程序无法启动,因为 ...

  10. CaiT:Facebook提出高性能深度ViT结构 | ICCV 2021

    CaiT通过LayerScale层来保证深度ViT训练的稳定性,加上将特征学习和分类信息提取隔离的class-attention层达到了很不错的性能,值得看看 来源:晓飞的算法工程笔记 公众号 论文: ...