圣杯布局和双飞翼布局

2018/10/23 posted in  CSS
Tags:  #CSS

圣杯

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Layout</title>
  <style media="screen">
  html * {
    padding: 0;
    margin: 0;
  }

  </style>
</head>

<body>
  <style>
  .container {
    padding-left: 220px;
    padding-right: 220px;
  }

  .left {
    float: left;
    width: 200px;
    height: 400px;
    background: red;
    margin-left: -100%;
    position: relative;
    left: -220px;
  }

  .center {
    float: left;
    width: 100%;
    height: 500px;
    background: yellow;
  }

  .right {
    float: left;
    width: 200px;
    height: 400px;
    background: blue;
    margin-left: -200px;
    position: relative;
    right: -220px;
  }

  </style>
  <article class="container">
    <div class="center">
      <h2>圣杯布局</h2>
    </div>
    <div class="left"></div>
    <div class="right"></div>
  </article>
</body>

</html>

双飞翼

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Layout</title>
    <style media="screen">
    html * {
        padding: 0;
        margin: 0;
    }
    </style>
</head>

<body>
    <style>
    .container {
        min-width: 600px;
    }

    .left {
        float: left;
        width: 200px;
        height: 400px;
        background: red;
        margin-left: -100%;
    }

    .center {
        float: left;
        width: 100%;
        height: 500px;
        background: yellow;
    }

    .center .inner {
        margin: 0 200px;
    }

    .right {
        float: left;
        width: 200px;
        height: 400px;
        background: blue;
        margin-left: -200px;
    }
    </style>
    <article class="container">
        <div class="center">
            <div class="inner">双飞翼布局</div>
        </div>
        <div class="left"></div>
        <div class="right"></div>
    </article>
</body>

</html>

« git clone、git pull和git fetch的用法及区别 Git合并特定commits 到另一个分支 »