美文网首页
三列布局之圣杯布局、双飞翼布局

三列布局之圣杯布局、双飞翼布局

作者: 2f1b6dfcc208 | 来源:发表于2017-12-17 20:30 被阅读14次
    • 圣杯布局
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            div{
                height:200px;
            }
            .container{
                padding:0 220px 0 320px;
            }
            .main{
                width:100%;
                float:left;
                background-color: #ccc;
            }
            .left{
                width:300px;
                float:left;
                margin-left: -100%;
                background-color: #e00;
                position: relative;
                left:-320px;
            }
            .right{
                width:200px;
                float: left;
                margin-left: -200px;
                background-color: #00e;
                position: relative;
                left:220px;
            }
        </style>
    </head>
    <body>
        <div class='container'>
            <div class='main'>main</div>
            <div class='left'>left</div>
            <div class ='right'>right</div>
        </div>
    </body>
    </html>
    
    • 双飞翼布局
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            div {
                height: 200px;
            }
            .main-wrap {
                width: 100%;
                float: left;
            }
            .main {
                background-color: #ccc;
                margin: 0 220px 0 320px;
            }
            .left {
                width: 300px;
                float: left;
                margin-left: -100%;
                background-color: #e00;
            }
            .right {
                width: 200px;
                float: left;
                margin-left: -200px;
                background-color: #00e;
            }
        </style>
    </head>
    <body>
        <div class='container'>
            <div class='main-wrap'>
                <div class='main'>main</div>
            </div>
            <div class='left'>left</div>
            <div class='right'>right</div>
        </div>
    </body>
    </html>
    

    使用flex弹性布局实现

    display:flex;
    flex-flow:row;
    

    相关文章

      网友评论

          本文标题:三列布局之圣杯布局、双飞翼布局

          本文链接:https://www.haomeiwen.com/subject/rqttwxtx.html