三栏布局,中间自适应,左右固定实现方法

强颜欢笑 提交于 2019-12-19 03:00:52

方法一:浮动

     <div class="container">
          <div class="content">hello</div>
          <div class="left"></div>
          <div class="right"></div>  
     </div>
 
     <style>
          .left{

               float:left;
               width: 200px;
               height: 300px;
               background: red;
          }
          .right{
               float: right;
               width: 200px;
               height: 300px;
               background: green;
          }
          .content{
               width: 100%;
               height: 300px;
               background: blue;
          }

     </style>
 
方法二:定位
       .left{
               width: 200px;
               height: 300px;
               background: red;
               position: absolute;
               left: 0;
               top: 0;

          }
          .right{
               width: 200px;
               height: 300px;
               background: green;
               position: absolute;
               right: 0;
               top: 0;

          }
          .content{
               width: 100%;
               height: 300px;
               background: blue;
               margin:0 200px;
          }
          .container{
               position:relative;
          }
 
方法三:display:box
          .left{
               width: 200px;
               height: 300px;
               background: red;
          }
          .right{
               width:200px;
               height: 300px;
               background: green;
          }
          .content{
               box-flex:1
               height: 300px;
               background: blue;
          }
          .container{
               display:box;
          }
 
 
 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!