zoukankan      html  css  js  c++  java
  • 页面布局(5)——三栏自适应布局(左右定宽中间自适应)

    三栏自适应布局(左右定宽中间自适应)

    方式一:浮动

    <section class="layout float">
          <style media="screen">
            .layout article div{
            min-height: 100px;
          }
          .layout.float .left{
            float:left;
            300px;
            background: red;
          }
          .layout.float .center{
            background: yellow;
          }
          .layout.float .right{
            float:right;
            300px;
            background: blue;
          }
          </style>
          <h1>三栏布局</h1>
          <article class="left-right-center">
            <div class="left"></div>
            <div class="right"></div>
            <div class="center">
              <h2>浮动解决方案</h2>
              <div>
                1.这是三栏布局的浮动解决方案;
                2.这是三栏布局的浮动解决方案;
                3.这是三栏布局的浮动解决方案;
                4.这是三栏布局的浮动解决方案;
                5.这是三栏布局的浮动解决方案;
                6.这是三栏布局的浮动解决方案;  
              </div>
    
            </div>
          </article>
        </section>
    

    方式二:绝对定位

     <section class="layout absolute">
          <style>
            .layout article div{
            min-height: 100px;
          }
            .layout.absolute .left-center-right>div{
              position: absolute;
            }
            .layout.absolute .left{
              left:0;
               300px;
              background: red;
            }
            .layout.absolute .center{
              left: 300px;
              right: 300px;
              background: yellow;
            }
            .layout.absolute .right{
              right:0;
               300px;
              background: blue;
            }
          </style>
          <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>
    

    方式三:flexbox

    <section class="layout flexbox">
          <style>
            .layout.flexbox{
              margin-top: 110px;
            }
            .layout.flexbox .left-center-right{
              display: flex;
            }
            .layout.flexbox .left{
               300px;
              background: red;
            }
            .layout.flexbox .center{
              flex:1;
              background: yellow;
            }
            .layout.flexbox .right{
               300px;
              background: blue;
            }
          </style>
          <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>
    

    方式四:表格样式

    <section class="layout table">
          <style>
            .layout.table .left-center-right{
              100%;
              height: 100px;
              display: table;
            }
            .layout.table .left-center-right>div{
              display: table-cell;
            }
            .layout.table .left{
               300px;
              background: red;
            }
            .layout.table .center{
              background: yellow;
            }
            .layout.table .right{
               300px;
              background: blue;
            }
          </style>
          <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>
    

    方式五:网格布局

    <section class="layout grid">
          <style>
            .layout.grid .left-center-right{
              100%;
              display: grid;
              grid-template-rows: 100px;
              grid-template-columns: 300px auto 300px;
            }
            .layout.grid .left-center-right>div{
    
            }
            .layout.grid .left{
               300px;
              background: red;
            }
            .layout.grid .center{
              background: yellow;
            }
            .layout.grid .right{
    
              background: blue;
            }
          </style>
          <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>
    

    方式六:calc计算宽度

    <section class="layout calc">
          <style>
            .layout.calc .left-center-right{
    
            }
            .layout.calc .left-center-right>div{
              min-height: 100px;
              display: inline-block;
              vertical-align: top;
            }
            .layout.calc .left{
               300px;
              background: red;
            }
            .layout.calc .center{
              background: yellow;
               calc(100% - 610px)
            }
            .layout.calc .right{
               300px;
              background: blue;
            }
          </style>
          <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>
    
  • 相关阅读:
    自定义DelegatingHandler为ASP.NET Web Api添加压缩与解压的功能
    搭建Linux环境--部署discuzx论坛
    搭建Linux环境--安装PHP
    搭建Linux环境--安装Apache
    搭建Linux环境--安装MySQL
    搭建Linux环境--安装tomcat
    搭建Linux环境--安装jdk
    vmware中安装了contes--解决ifconfig无法执行
    设计模式(四)原型模式
    设计模式(三)建造者模式
  • 原文地址:https://www.cnblogs.com/janas-luo/p/9605345.html
Copyright © 2011-2022 走看看