# css圣杯布局

1.三列布局,中间宽度自适应,两边定宽,

2.中间栏要在浏览器中优先展示渲染

3.原理:可以利用float浮动relative+margin、padding负值的方式实现,具体看代码。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>css圣杯布局</title>
  <style type="text/css">
    .wrap {
      width: 700px;
      margin: 0 auto;
    }

    .top,
    .footer {
      height: 100px;
      background-color: #ccc;
    }

    .main {
      padding: 0 100px;
      overflow: hidden;
    }

    .main .left,
    .main .content,
    .main .right {
      position: relative;
      float: left;
      margin-bottom: -2000px;
      padding-bottom: 2000px;
      background-color: red;
    }

    .main .left {
      width: 100px;
      left: -100px; 
      background-color: green;
    }

    .main .content {
      width: 100%;
      background-color: red;
      margin-left: -100px;
    }

    .main .right {
      left: 100px;
      width: 100px;
      background-color: blue;
      margin-left: -100px;
    }
  </style>
</head>
<body>
  <div class="wrap">
    <div class="top"></div>
    <div class="main">
      <div class="left">左</div>
      <div class="content">中</br>123</br>123</div>
      <div class="right">右</div>
    </div>
    <div class="footer"></div>
  </div>
</body>
</html>