Skip to content

三栏布局

html
<section class="layout float">
  <style media="screen">
    .layout.float .left {
      float: left;
      width: 300px;
      background: red;
    }
    .layout.float .center {
      background: yellow;
    }
    .layout.float .right {
      float: right;
      width: 300px;
      background: blue;
    }
  </style>
  <h1>三栏布局</h1>
  <article class="left-right-center">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
      <h2>浮动解决方案</h2>
      1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案;
      3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案;
      5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
    </div>
  </article>
</section>
html
<section class="layout absolute">
  <style>
    .layout.absolute .left-center-right > div {
      position: absolute;
    }
    .layout.absolute .left {
      left: 0;
      width: 300px;
      background: red;
    }
    .layout.absolute .center {
      left: 300px;
      right: 300px;
      background: yellow;
    }
    .layout.absolute .right {
      right: 0;
      width: 300px;
      background: blue;
    }
  </style>
  <h1>三栏布局</h1>
  <article class="left-center-right">
    <div class="left"></div>
    <div class="center">
      <h2>绝对定位解决方案</h2>
      1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案;
      3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案;
      5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
    </div>
    <div class="right"></div>
  </article>
</section>
html
<section class="layout flexbox">
  <style>
    .layout.flexbox {
      margin-top: 110px;
    }
    .layout.flexbox .left-center-right {
      display: flex;
    }
    .layout.flexbox .left {
      width: 300px;
      background: red;
    }
    .layout.flexbox .center {
      flex: 1;
      background: yellow;
    }
    .layout.flexbox .right {
      width: 300px;
      background: blue;
    }
  </style>
  <h1>三栏布局</h1>
  <article class="left-center-right">
    <div class="left"></div>
    <div class="center">
      <h2>flexbox解决方案</h2>
      1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案;
      3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案;
      5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
    </div>
    <div class="right"></div>
  </article>
</section>
html
<section class="layout table">
  <style>
    .layout.table .left-center-right {
      width: 100%;
      height: 100px;
      display: table;
    }
    .layout.table .left-center-right > div {
      display: table-cell;
    }
    .layout.table .left {
      width: 300px;
      background: red;
    }
    .layout.table .center {
      background: yellow;
    }
    .layout.table .right {
      width: 300px;
      background: blue;
    }
  </style>
  <h1>三栏布局</h1>
  <article class="left-center-right">
    <div class="left"></div>
    <div class="center">
      <h2>表格布局解决方案</h2>
      1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案;
      3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案;
      5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
    </div>
    <div class="right"></div>
  </article>
</section>
html
<section class="layout grid">
  <style>
    .layout.grid .left-center-right {
      width: 100%;
      display: grid;
      grid-template-rows: 100px;
      grid-template-columns: 300px auto 300px;
    }
    .layout.grid .left-center-right > div {
    }
    .layout.grid .left {
      width: 300px;
      background: red;
    }
    .layout.grid .center {
      background: yellow;
    }
    .layout.grid .right {
      background: blue;
    }
  </style>
  <h1>三栏布局</h1>
  <article class="left-center-right">
    <div class="left"></div>
    <div class="center">
      <h2>网格布局解决方案</h2>
      1.这是三栏布局的浮动解决方案; 2.这是三栏布局的浮动解决方案;
      3.这是三栏布局的浮动解决方案; 4.这是三栏布局的浮动解决方案;
      5.这是三栏布局的浮动解决方案; 6.这是三栏布局的浮动解决方案;
    </div>
    <div class="right"></div>
  </article>
</section>

未知宽高元素水平垂直居中

html
<div class="father">
  <div class="son"></div>
</div>

//第一种
<style>
  .father {
    position: relative;
    width: 500px;
    height: 500px;
    background-color: red;
  }
  .son {
    position: absolute;
    margin: auto;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 300px;
    height: 300px;
    background-color: blue;
  }
</style>

//第二种
<style>
  .father {
    position: relative;
  }
  .son {
    margin: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
</style>

//第三种
<style>
  .father {
    display: -webkit-flex;
    align-items: center;
    justify-content: center;
  }
  .son {
    margin: auto;
  }
</style>

//第四种,用表格布局
<div class="pe">
  <div class="he">
    <div class="she"></div>
  </div>
</div>
<style>
  .pe {
    display: table;
    width: 50%;
    height: 30%;
    position: absolute;
  }
  .he {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
  }
  .she {
    width: 50%;
    height: 30%;
    display: inline-block;
  }
</style>

//第五种,行内块元素
<div class="wrap">
  <b class="vamp"></b>
  <div class="test">行内块元素</div>
  <div>
    <style>
      .vamp{
        width:0
        height:100%;
        vertical-align:middle;
      }
      .test{
        background:"blue";
        display:inline-block;
      }
    </style>
  </div>
</div>

Layout Switch

Adjust the layout style of VitePress to adapt to different reading needs and screens.

Expand all
The sidebar and content area occupy the entire width of the screen.
Expand sidebar with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Expand all with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Original width
The original layout width of VitePress

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.

Spotlight

Highlight the line where the mouse is currently hovering in the content to optimize for users who may have reading and focusing difficulties.

ONOn
Turn on Spotlight.
OFFOff
Turn off Spotlight.