ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

三栏布局

2020-05-14 13:52:47  阅读:197  来源: 互联网

标签:layout 三栏 解决方案 布局 background left


 

  1.使用绝对定位 position: absolute;

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Layout</title>
    <style media="screen">
        html * {
            padding: 0;
            margin: 0;
        }
        .layout article div {
            min-height: 150px;
        }
        .layout.absolute .left-center-right>div{
            position: absolute;
        }
        .layout.absolute .left {
            left:0;
            width: 300px;
            background: red;
        }

        .layout.absolute .center {
            left: 300px;
            right: 300px;
            background: yellow;
        }

        .layout.absolute .right {
            right: 0;
            width: 300px;
            background: blue;
        }
    </style>
</head>
<body>
    <!--绝对布局  -->
    <section class="layout absolute">
        <h1>三栏布局</h1>
        <article class="left-center-right">
            <div class="left"></div>
            <div class="center">
                <h2>绝对定位解决方案</h2>
                1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案; 3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案; 5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
            </div>
            <div class="right"> 1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案; 3.这是三栏布局的浮动解决方案 1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案; 3.这是三栏布局的浮动解决方案</div>
        </article>
    </section>
</body>
</html>
View Code

  2.双飞翼布局

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Layout</title>
    <style media="screen">
    html * {
        padding: 0;
        margin: 0;
    }
    </style>
</head>

<body>
    <style>
    .container {
        min-width: 600px;
    }

    .left {
        float: left;
        width: 200px;
        height: 400px;
        background: red;
        margin-left: -100%;
    }

    .center {
        float: left;
        width: 100%;
        height: 500px;
        background: yellow;
    }

    .center .inner {
        margin: 0 200px;
    }

    .right {
        float: left;
        width: 200px;
        height: 400px;
        background: blue;
        margin-left: -200px;
    }
    </style>
    <article class="container">
        <div class="center">
            <div class="inner">双飞翼布局</div>
        </div>
        <div class="left">left</div>
        <div class="right">right</div>
    </article>
</body>

</html>

  3.flex布局

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Layout</title>
    <style media="screen">
        html * {
            padding: 0;
            margin: 0;
        }
        .layout article div {
            min-height: 150px;
        }
        .layout.flexbox .left-center-right{
            display: flex;
        }
        
        .layout.flexbox .left {
            width: 300px;
            background: red;
        }
        .layout.flexbox .center {
            background: yellow;
            flex: 1;
        }
        .layout.flexbox .right {
            width: 300px;
            background: blue;
        }
    </style>
</head>
<body>
    <!--flexbox  -->
    <section class="layout flexbox">
        <h1>三栏布局</h1>
        <article class="left-center-right">
            <div class="left"></div>
            <div class="center">
                <h2>flexbox解决方案</h2>
                1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案; 3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案; 5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
            </div>
            <div class="right"></div>
        </article>
    </section>
</body>
</html>

  4.浮动布局

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Layout</title>
    <style media="screen">
        html * {
            padding: 0;
            margin: 0;
        }
        .layout article div {
            min-height: 150px;
        }
        .layout.float .left {
            float: left;
            width: 300px;
            background: red;
        }

        .layout.float .center {
            background: yellow;
        }

        .layout.float .right {
            float: right;
            width: 300px;
            background: blue;
        }
    </style>
</head>
<body>
    <!--浮动布局  -->
    <section class="layout float">
        <h1>三栏布局</h1>
        <article class="left-right-center">
            <div class="left"></div>
            <div class="right"></div>
            <div class="center">
                <h2>浮动解决方案</h2>
                1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案; 3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案; 5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
            </div>
        </article>
    </section>
</body>
</html>

  5.表格布局

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Layout</title>
    <style media="screen">
        html * {
            padding: 0;
            margin: 0;
        }

        .layout article div {
            min-height: 150px;
        }
        .layout.table .left-center-right {
            display: table;
            height: 150px;
            width: 100%;
        }

        .layout.table .left-center-right>div {
            display: table-cell;
        }

        .layout.table .left {
            width: 300px;
            background: red;
        }

        .layout.table .center {
            background: yellow;
        }

        .layout.table .right {
            width: 300px;
            background: blue;
        }
    </style>
</head>

<body>
    <!--表格布局-->
    <section class="layout table">
        <h1>三栏布局</h1>
        <article class="left-center-right">
            <div class="left"></div>
            <div class="center">
                <h2>表格布局解决方案</h2>
                1.这是三栏布局的表格布局解决方案; 2.这是三栏布局的表格布局解决方案; 3.这是三栏布局的表格布局解决方案; 4.这是三栏布局的表格布局解决方案; 5.这是三栏布局的表格布局解决方案; 6.这是三栏布局的表格布局解决方案;
            </div>
            <div class="right"></div>
        </article>
    </section>
</body>
</html>

  6.网格(grid)布局

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Layout</title>
    <style media="screen">
        html * {
            padding: 0;
            margin: 0;
        }

        .layout article div {
            min-height: 150px;
        }
        .layout.grid .left-center-right {
            display: grid;
            width: 100%;
            grid-template-columns: 300px auto 300px;
            grid-template-rows: 150px;
        }
        .layout.grid .left {
            background: red;
        }
        .layout.grid .center {
            background: yellow;
        }
        .layout.grid .right {
            background: blue;
        }
    </style>
</head>

<body>
    <!--网格布局-->
    <section class="layout grid">
        <h1>三栏布局</h1>
        <article class="left-center-right">
            <div class="left"></div>
            <div class="center">
                <h2>网格布局解决方案</h2>
                1.这是三栏布局的网格(grid)布局解决方案; 2.这是三栏布局的网格(grid)布局解决方案; 3.这是三栏布局的网格(grid)布局解决方案; 4.这是三栏布局的网格(grid)布局解决方案; 5.这是三栏布局的网格(grid)布局解决方案; 6.这是三栏布局的网格(grid)布局解决方案;
            </div>
            <div class="right"></div>
        </article>
    </section>
</body>
</html>

  

 

标签:layout,三栏,解决方案,布局,background,left
来源: https://www.cnblogs.com/dadouF4/p/12888170.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有