经典三栏布局相关

三栏布局(如果高度已知的话)

float解决方案

高度未知失效

    <section class="layout float">
        <article class="left-right-center">
            <style media="screen">
               .layout.float .left{
                  float: left;
                  width: 300px;
                  background: blue;
               }
               .layout.float .right{
                  float: right;
                  width: 300px;
                  background:blue;
               }
               .layout.float .center{
                  background:red;
               }       
            </style>
             <div class="left"></div>  
             <div class="right"></div>   
             <div class="center">
                 <h1>浮动解决方案</h1>
                 1.三栏
                 2.三栏
                 3.三滥
             </div>

        </article>
    </section>

绝对定位

高度未知失效

  <section class="layout absolute">
        <article class="left-center-right">
            <style media="screen">
                .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: blue;
                }
                .layout.absolute .right{
                    right: 0;
                    width: 300px;
                    background: red;
                }
            </style>
             <div class="left"></div>  
             <div class="right"></div>   
             <div class="center">
                 <h1>绝对定位解决方案</h1>
                 1.三栏
                 2.三栏
                 3.三滥
             </div>

        </article>
    </section>

flexbox解决方案

  <section class="layout flex">
        <article class="left-center-right">
            <style media="screen">
                .layout.flex .left-center-right{
                  display: flex;
                }
                .layout.flex .left{
                    width: 300px;
                    background: red;
                }
                .layout.flex .right{
                    width: 300px;
                    background: red;
                }
                .layout.flex .center{
                    flex:1;
                    background: blue;
                }
            </style>
             <div class="left"></div>  

             <div class="center">
                 <h1>flex解决方案</h1>
                 1.三栏
                 2.三栏
                 3.三滥
             </div>
             <div class="right"></div>

        </article>
    </section>

表格布局

   <section class="layout table">
        <article class="left-center-right">
            <style media="screen">
              .layout.table  .left-center-right{
                  width: 100%;
                  display: table;
                  height: 100px;
              } 
              .layout.table .left-center-right>div{
                display: table-cell;
              }
              .layout.table .left{
                 width: 300px;
                 background: red;
              }
              .layout.table .center{
                 background: blue;
              }
              .layout.table .right{
                 width: 300px;
                 background: red;
              }
            </style>
             <div class="left"></div>  

             <div class="center">
                 <h1>表哥解决方案</h1>
                 1.三栏
                 2.三栏
                 3.三滥
             </div>
             <div class="right"></div>

        </article>
    </section>

网格布局

高度未知失效

网格布局新出的,兼容性一般,

   <section class="layout grid">
        <article class="left-center-right">
            <style media="screen">
              .layout.grid  .left-center-right{
                display: grid;
                width: 100%;
                grid-template-rows: 100px;
                grid-template-columns: 300px auto 300px;
              }
              .layout.grid .left{
                  background: red;
              }
              .layout.grid .center{
                  background: blue;
              }
              .layout.grid .right{
                  background: red;
              }

            </style>
             <div class="left"></div>  

             <div class="center">
                 <h1>网格解决方案</h1>
                 1.三栏
                 2.三栏
                 3.三滥
             </div>
             <div class="right"></div>

        </article>
    </section>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值