• 等高布局


    1、使用margin负边距:

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
      <title>JS Bin</title>
      <style type="text/css">
        .parent{
          position:relative;
          overflow:hidden;
        }
        .left{
          background:red;
          left:0px;
        }
        .center{
          background:yellow;
        }
        .right{
          background:green;
        }
        .left,.center,.right{
          float:left;    
           padding-bottom: 500px;
          margin-bottom: -500px;
        }
        
      </style>
    </head>
    <body>
    <div class="parent">
        <div class="left">
            <p>left</p>
        </div>  
        <div class="center">
            <p>center</p>
            <p>center</p>
        </div>          
        <div class="right">
            <p>right</p>
        </div>        
    </div>
    </body>
    </html>
    

     2、使用table

    <html>
    <head>
    <style type="text/css">
    body,p{margin: 0;}
    .parent{
        display: table;
         100%;
        table-layout: fixed;
    }
    .left,.centerWrap,.right{
        display: table-cell;
    }
    .center{
        margin: 0 20px;
    }
    </style>
    </head>
    <body>
    <div class="parent" style="background-color: lightgrey;">
        <div class="left" style="background-color: lightblue;">
            <p>left</p>
        </div>  
        <div class="centerWrap">
            <div class="center" style="background-color: pink;">
                <p>center</p>
                <p>center</p>
            </div>         
        </div> 
        <div class="right" style="background-color: lightgreen;">
            <p>right</p>
        </div>        
    </div>
    </body>
    </html>
    

    3、使用flex

    <html>
    <head>
    <style>
    body,p{margin: 0;}
    .parent{
        display: flex;
    }
    .left,.center,.right{
        flex: 1;
    }
    .center{
        margin: 0 20px;
    }
    </style>
    </head>
    <body>
    <div class="parent" style="background-color: lightgrey;">
        <div class="left" style="background-color: lightblue;">
            <p>left</p>
        </div>  
        <div class="center" style="background-color: pink;">
            <p>center</p>
            <p>center</p>
        </div>          
        <div class="right" style="background-color: lightgreen;">
            <p>right</p>
        </div>        
    </div>
    </body>
    </html>
    

     4、使用grid

    <html>
    <head>
    <style>
    body,p{margin: 0;}
    .parent{
        display: grid;
        grid-auto-flow: column;
        grid-gap:20px;
    }
    </style>
    </head>
    <body>
    <div class="parent" style="background-color: lightgrey;">
        <div class="left" style="background-color: lightblue;">
            <p>left</p>
        </div>  
        <div class="center" style="background-color: pink;">
            <p>center</p>
            <p>center</p>
        </div>          
        <div class="right" style="background-color: lightgreen;">
            <p>right</p>
        </div>        
    </div>
    </body>
    </html>
    

     推荐使用table和margin负边距,简单好用,不存在兼容性

    gird,flex也很简单,但是兼容性不太好

    学而不思则罔,思而不结则殆,结而不看,一事无成
  • 相关阅读:
    CSS HACK:IE6、IE7、IE8、Firefox兼容性问题解决方案
    C# @符号的多种使用方法
    16个Javascript的Web UI库、框架及工具包
    【分享】20个很不错的UI图标集资源
    JQuery/AjaX/Javascript/DIV+CSS资源下载地址
    发个csdn泄露账户查询地址,没下数据库的童鞋来查一下自己
    【总结】CSS透明度大汇总
    C#综合揭秘——细说事务
    ASP.NET获取客户端、服务器端基础信息集合
    收集的网络上大型的开源图像处理软件代码(提供下载链接)
  • 原文地址:https://www.cnblogs.com/windseek/p/8489434.html
Copyright © 2020-2023  润新知