vuepress-theme-vdoing/docs/02.页面/20.CSS/04.flex布局案例-圣杯布局.md

1.2 KiB
Raw Blame History

title date permalink categories tags author
flex布局案例-圣杯布局 2019-12-25 14:27:01 /pages/df9e7c7214fa5046
页面
CSS
null
name link
xugaoyi https://github.com/xugaoyi

flex布局案例-圣杯布局

可用F12开发者工具查看元素及样式可打开codepen在线编辑代码。

::: demo [vanilla]

<html>
  <div class="HolyGrail">
    <header>#header</header>
    <div class="wrap">
      <nav class="left">left 宽度固定200px</nav>
      <main class="content">center 宽度自适应</main>
      <aside class="right">right 宽度固定200px</aside>
    </div>
    <footer>#footer</footer>
  </div>
</html>
<style>
  .HolyGrail {
    text-align: center;
    display: flex;
    min-height: 40vh;
    flex-direction: column;
  }
  .HolyGrail .wrap {
    display: flex;
    flex: 1;
  }
  .HolyGrail .content {
    background: #eee;
    flex: 1;
  }
  .HolyGrail .left,.HolyGrail .right {
    background:lightgreen;
    flex: 0 0 200px;
  }
  .HolyGrail header,.HolyGrail footer{
    background:#999;
    height: 50px;
    line-height: 50px;
  }
  .HolyGrail .left {
    background:salmon;
  }
</style>

:::

参考:http://www.ruanyifeng.com/blog/2015/07/flex-examples.html