实现圣杯布局的 css 方案

时间:2020-02-17 22:20:11   收藏:0   阅读:68

实现圣杯布局的 css 方案

float 实现

<div class="float">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
</div>
.left {
    float: left;
}
.right {
    float: right;
}

 

position 实现

<div class="layout">
    <div class="left"></div>
    <div class="center"></div>
    <div class="right"></div>
</div>
.layout {
    position: relative;
}

.left {
    background-color: red;
    position: absolute;
    width: 200px;
    left: 0;
    top: 0;
}

.right {
    background-color: red;
    position: absolute;
    width: 200px;
    right: 0;
    top: 0;
}

.center {
    background-color: skyblue;
    left: 200px;
    right: 200px;
    top: 0;
}

 

table 实现

<div class="layout">
    <div class="left"></div>
    <div class="center"></div>
    <div class="right"></div>
</div>
.layout div {
    height: 200px;
    display: table-cell;
}

.left, .right {
    width: 200px;
    background: red;
}

.center {
    background: skyblue;
}

原文:https://www.cnblogs.com/sosoyi/p/12323752.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!