圣杯布局 float left + float right

使用 float left + float right 创建 圣杯布局

by Boyanliuu

HTML

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>圣杯布局</title>
    </head>
    <body>
        <header> header</header>
        <div class="clearfix wrapper">

            <div class="left">
                Left content
            </div>

            <div class="right">
                right content
            </div>
            <div class="center">
                Main content
            </div>
        </div>
        <footer> footer</footer>
    </body>
</html>

CSS

:root {
    box-sizing: border-box;
}

*,
::before,
::after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}


.center{
  background:lightblue;
}

.left{
  background:gold;
}
.right{
  background:yellow;
}
footer , header{
  background:CornflowerBlue;
}

.clearfix::after{
  content: "";
  display:block;
  clear: both;
}


.center,.left,.right{
  text-align:center;
  
}
.left,.right{
  width:100px;
}


.left{
  float:left;
}
.right{
  float:right;
}