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. vue 获取当前元素

    获取当前元素 Html: <li><a href="#" v-on:click="typeStyle">萨克斯萨克<span> ...

  2. .h头文件 .lib动态链接库文件 .dll 动态链接库

    (1).h头文件是编译时必须的,lib是链接时需要的,dll是运行时需要的. 附加依赖项的是.lib 不是.dll 若生成了DLL ,则肯定也生成 LIB文件 如果要完成源代码的编译和链接,有头文件和 ...

  3. 查看JDK的安装路径 和 安装版本

    查看JDK的安装路径: 打开 运行,输入 cmd .  输入: java -verbose                      (ps:java后面必须敲一个空白格) 得到下图:  最后的两行, ...

  4. [转]WinForm实现win7 Aero磨砂效果介绍

    WinForm实现win7 Aero磨砂效果如下: WinForm实现win7 Aero磨砂效果代码如下: using System; using System.Collections.Generic ...

  5. KeyOnlyFilter(2)

    主要用来过滤剩下行键计数一类 KeyOnlyFilter 官方API解释如下: A filter that will only return the key component of each KV ...

  6. WebConfig配置文件

    <?xml version="1.0"?> <!--注意: 除了手动编辑此文件以外,您还可以使用 Web 管理工具来配置应用程序的设置.可以使用 Visual S ...

  7. 2019-8-31-dotnet-控制台读写-Sqlite-提示-no-such-table-找不到文件

    title author date CreateTime categories dotnet 控制台读写 Sqlite 提示 no such table 找不到文件 lindexi 2019-08-3 ...

  8. JosnRpcClient

    <?php /** * Simple JSON-RPC interface. */ namespace org; class JosnRpcClient{ protected $host; pr ...

  9. goland设置颜色和字体

  10. .NET CORE中Encoding对GB2312等编码的支持

    最近.NET CORE做网络爬虫的时候,遇到了charset=gbk,转码的时候,发现直接使用Encoding.GetEncoding(“GB2312”)抛异常了.好吧,看到这个的时候,我是一脸懵逼的 ...