圣杯布局2019-12-18

圣杯布局

css

<style>
    * {
        margin: 0;
        padding: 0;
    }
    .container {
        width: calc(100% - 300px);
        padding: 0 150px;
        height: 300px;
        background: red;
    }
    .fl {
        float: left;
    }
    .center {
        width: 100%;
        height: 300px;
        background: aqua;
    }
    .left {
        width: 150px;
        height: 300px;
        background-color: #1a1aff;
        margin-left: -100%;
        position: relative;
        left: -150px;
    }
    .right {
        width: 150px;
        margin-right:-150px ;
        height: 300px;
        background-color: #ff2bd1;
    }
</style>

html

<div class="container">
    <div class="center fl"></div>
    <div class="left fl"></div>
    <div class="right fl"></div>
    <div style="clear: both"></div>
</div>

双飞翼布局

css

<style>
body {
    min-width: 500px;
}

#container {
    width: 100%;
}

.fl {
    float: left;
}

#center {
    margin-left: 200px;
    margin-right: 150px;
    background-color: #ff5c3c;
}

#left {
    width: 200px;
    margin-left: -100%;
    background-color: #95ff3f;
}

#right {
    width: 150px;
    margin-left: -150px;
}

#footer {
    clear: both;
}
</style>

html

<div id="header"></div>
<div id="container" class="fl">
    <div id="center">123</div>
</div>
<div id="left" class="fl">123</div>
<div id="right" class="fl">123</div>
<div id="footer"></div>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容