float浮动

<section class="layout float">
<style media="screen">
.layout.float .left{
float: left;
width: 300px;
background: pink;
}
.layout.float .right{
float: right;
width: 300px;
background: lightblue;
}
.layout.float .center {
background: lightyellow;
}
</style>
<article class="left-right-center">
<div class="left"></div>
<div class="right"></div>
<div class="center">
<h1>浮动解决方案</h1>
1.这是三栏布局中的中间部分
2.这是三栏布局中的中间部分
</div>
</article>
</section>

absolute绝对定位

<section class="layout absolute">
<style media="screen">
.layout.absolute .left-right-center>div {
position: absolute;
}
.layout.absolute .left {
width: 300px;
left: 0;
background: lightblue;
}
.layout.absolute .right {
width: 300px;
right: 0;
background: lightgreen;
}
.layout.absolute .center {
left: 300px;
right: 300px;
background: pink;
}
</style>
<article class="left-right-center">
<div class="left"></div>
<div class="right"></div>
<div class="center">
<h1>绝对定位解决方案</h1>
2.这是三栏布局的中间部分
</div>
</article>
</section>

flex布局

<section class="layout flexbox">
<style media="screen">
.layout.flexbox .left-center-right {
margin-top: 140px;
display: flex;
}
.layout.flexbox .left {
width: 300px;
background: lightcoral;
}
.layout.flexbox .center {
flex:1;
background: lightgray;
}
.layout.flexbox .center2 {
flex:1; /*按照数字的比例自动分配剩余空间*/
background: lightgreen;
}
.layout.flexbox .right {
width: 300px;
background: lightblue;
}
</style>
<article class="left-center-right">
<div class="left"></div>
<div class="center">
<h1>flex布局解决方案</h1>
3.这是三栏布局的中间部分
</div>
<div class="center2">
<h1>flex布局解决方案</h1>
3.这是三栏布局的中间部分
</div>
<div class="right"></div>
</article>
</section>

table布局

<section class="layout table">
<style>
.layout.table .left-center-right {
width: 100%;
height: 100px;
display: table;
}
.layout.table .left-center-right>div {
display: table-cell;
}
.layout.table .left {
width: 300px;
background: lightgreen;
}
.layout.table .center {
background: pink;
}
.layout.table .right {
width: 300px;
background: lightblue;
}
</style>
<article class="left-center-right">
<div class="left"></div>
<div class="center">
<h1>table解决方案</h1>
4.这是三栏布局的中间部分
</div>
<div class="right"></div>
</article>
</section>

grid网格布局

<section class="layout grid">
<style>
.layout.grid .left-center-right {
display: grid;
width: 100%;
grid-template-rows:100px;
grid-template-columns:300px auto 300px;
}
.left {
background: lightgreen;
}
.center {
background: pink;
}
.right {
background: lightblue;
}
</style>
<article class="left-center-right">
<div class="left"></div>
<div class="center">
<h1>网格布局解决方案</h1>
5.这是三栏布局的中间部分
</div>
<div class="right"></div>
</article>
</section>

用五种不同的布局方式实现“左右300px中间自适应”的效果的更多相关文章

  1. iOS五种本地缓存数据方式

    iOS五种本地缓存数据方式   iOS本地缓存数据方式有五种:前言 1.直接写文件方式:可以存储的对象有NSString.NSArray.NSDictionary.NSData.NSNumber,数据 ...

  2. JavaScript常见的五种数组去重的方式

    ▓▓▓▓▓▓ 大致介绍 JavaScript的数组去重问题在许多面试中都会遇到,现在做个总结 先来建立一个数组 var arr = [1,2,3,3,2,'我','我',34,'我的',NaN,NaN ...

  3. Java中五种遍历HashMap的方式

    import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Java8Templat ...

  4. 五种团队的组织方式落地 DevOps

    原文链接:https://blog.matthewskelton.net/2013/10/22/what-team-structure-is-right-for-devops-to-flourish/ ...

  5. 只要一行代码,实现五种 CSS 经典布局

    常用的页面布局,其实就那么几个.下面我会介绍5个经典布局,只要掌握了它们,就能应对绝大多数常规页面. 这几个布局都是自适应的,自动适配桌面设备和移动设备.代码实现很简单,核心代码只有一行,有很大的学习 ...

  6. 【Android 复习】:Android五种布局的使用方法

    ---恢复内容开始--- 在Android布局中,有五种常用的布局,下面我们就来学习一下这几种布局的使用方式 1) 线性布局:LinearLayout 2) 帧布局:  FrameLayout 3)  ...

  7. Android开发之基本控件和详解四种布局方式

    Android中的控件的使用方式和iOS中控件的使用方式基本相同,都是事件驱动.给控件添加事件也有接口回调和委托代理的方式.今天这篇博客就总结一下Android中常用的基本控件以及布局方式.说到布局方 ...

  8. Ngui 五种点击事件实现方式及在3d场景中点透的情况

    http://www.unity蛮牛.com/thread-22018-1-1.html ngui作为unity界面插件之一中,无疑是最好用,使用最多的了从自学unity到现在界面一直使用它 由于它的 ...

  9. ASP.NET Core中配置监听URLs的五种方式

    原文: 5 ways to set the URLs for an ASP.NET Core app 作者: Andrew Lock 译者: Lamond Lu 默认情况下,ASP. NET Core ...

随机推荐

  1. python 日记 day5 字典

    一.数据类型分为: 1.不可变数据类型:元组,bool,int,str (不可更改的又叫可哈希) 2.可变数据类型 :list,dict ,set   (可变的又叫不可哈希) 字典: 优点:1.可二分 ...

  2. Leetcode150. Evaluate Reverse Polish Notation逆波兰表达式求值

    根据逆波兰表示法,求表达式的值. 有效的运算符包括 +, -, *, / .每个运算对象可以是整数,也可以是另一个逆波兰表达式. 说明: 整数除法只保留整数部分. 给定逆波兰表达式总是有效的.换句话说 ...

  3. Leetcode551.Student Attendance Record I学生出勤记录1

    给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果一个学生的出勤纪录中不超过一个' ...

  4. 谷歌浏览器flash被禁用解决方法

    谷歌浏览器访问设置:chrome://settings/content/flash 把要启动flash插件的网址添加进去

  5. useradd -M -s /sbin/nologin mysql -g mysql 报错 Creating mailbox file

    由于之前使用以下命令删除了mysql账户 userdel mysql groupdel mysql      #如果删除了mysql用户,对应的组也会被删除(只有一个用户的情况下) 执行以下命令时报错 ...

  6. UnhandledPromiseRejectionWarning: SequelizeConnectionError: Client does not support authentication protocol requested by server; consider upgrading MySQL client

    UnhandledPromiseRejectionWarning: SequelizeConnectionError: Client does not support authentication p ...

  7. Cannot allocate memory for the buffer pool

    优化了一通,启动不了 直接上日志 innodb_buffer_pool_size”.”key_buffer_size” 的大小设置,适当的调大内存分配,减小,然后保存配置文件,重新尝试启mysql 成 ...

  8. request.setCharacterEncoding("utf-8");

    request.setCharacterEncoding("utf-8");不加这句话时,从input控件得到值要用new String(request.getParameter( ...

  9. springMVC--动态验证码实现

    在网站开发过程中我们一般都会为了防止用户连续提交都会提供验证码的功能,简单来说就是生成一个动态图片,在图片中保存一些校验信息,将校验信息放到session中和用户提交的验证码信息进行对比,如果出现错误 ...

  10. JSP-Cookie和Session

    1 会话技术简介 1.1 存储客户端状态 1.2 会话技术 2 Cookie技术 2.1 Cookie技术的购物 2.2 服务器端向客户端发Cookie //1.创建cookie对象 Cookie c ...