圣杯布局和雙飛燕布局實(shí)現(xiàn)左右兩列固定中間自適應(yīng)

圣杯布局

<!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>
        .container{
            overflow: hidden;
            padding: 0 100px;
        }
        .middle{
            width: 100%;
            height: 200px;
            background-color: aquamarine;
            float: left;
        }
        .left{
            position: relative;
            left: -200px;
            margin-left: -100%;
            width: 200px;
            height: 200px;
            background-color: blueviolet;
            float: left;
        }
        .right{
            position: relative;
            right: -200px;
            margin-left: -200px;
            width: 200px;
            height: 200px;
            background-color: blue;
            float: left;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="middle">sssxcwwwwwwsssss中間區(qū)域</div>
        <div class="left">左邊區(qū)域</div>
        <div class="right">右邊區(qū)域</div>
    </div> 
</body>
</html>
兩側(cè)固定中間自適應(yīng).png

雙飛燕布局

<!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>
</head>

<body>
    <div class="wrapper">
        <div class="main">
            <div class="inner">
                main
            </div>
        </div>
        <div class="left">left</div>
        <div class="right">right</div>
    </div>
     <style>
        .main,.left,.right{
            height: 100px;
            float: left;
        }
        .main{
            width: 100%;
            background-color: aqua;
        }
        .left{
            width:120px;
            margin-left: -100%;
            background-color:cornflowerblue;
        }
        .right{
            width: 120px;
            margin-left: -120px;
            background-color: cadetblue;
        }
        .inner{
            margin-left:120px;
            margin-right: 120px;
        }
     </style>
</body>
// 雙飛燕布局少了定位,就是在中間的div多嵌套了一個(gè)div,利用margin的屬性去控制,相對(duì)于圣杯布局簡(jiǎn)潔了不少
效果都是一樣
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容