三栏布局总结

158 阅读1分钟

方法一

****弹性盒子模型
 <style>
 .content{
        height: 500px;
        width:100%;
        display: flex;
    }     
    .left{
        width:150px;
        height:500px;
        background: red;
    }
    .right{
        height:500px;
        width:150px;
        background: rgb(40, 185, 113);
    }
    .center{
        flex:1;        
        background: rgb(35, 11, 138);
    }
 </style>

<div class="content">
        <div class="left"></div>
        <div class="center"></div>
        <div class="right"></div class="right">

</div>

方法二 浮动

 <style>
          html,body{
            padding: 0;
            margin: 0;
        }
        
        /* 浮动布局 */
        .left,.right{
            width: 300px;
            height: 200px;
            background-color: #ffe6b8;
        }
        .left{
            float: left;
        }

        .right{
            float: right;
        }

        .center{
            height: 200px;
            background-color: #a0b3d6
        }
       
      </style>

<div class="content">
        <div class="left"></div>
        <div class="center"></div>
        <div class="right"></div class="right">

</div>