my_blog icon indicating copy to clipboard operation
my_blog copied to clipboard

CSS 006:CSS如何进行圣杯布局 新增 Grid 布局方法

Open wjq990112 opened this issue 5 years ago • 2 comments
trafficstars

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      header {
        height: 100px;
        line-height: 100px;
        text-align: center;
        color: #fff;
        background: red;
      }

      footer {
        height: 100px;
        line-height: 100px;
        text-align: center;
        color: #fff;
        background: red;
      }

      main {
        display: grid;
        height: 200px;
        line-height: 200px;
        text-align: center;
        grid-template-columns: 200px auto 200px;  // 此处可以使用 template-columns 属性对列进行划分
      }

      aside {
        background: yellow;
      }

      article {
        color: #fff;
        background: #1890ff;
      }
    </style>
  </head>

  <body>
    <header>这是头部</header>
    <main>
      <aside>左边栏</aside>
      <article>文章</article>
      <aside>右边栏</aside>
    </main>
    <footer>这是页脚</footer>
  </body>
</html>

wjq990112 avatar Feb 28 '20 02:02 wjq990112

效果如下图: 圣杯布局(grid)

wjq990112 avatar Feb 28 '20 02:02 wjq990112

好的

sanyuan0704 avatar Feb 28 '20 08:02 sanyuan0704