>  기사  >  웹 프론트엔드  >  CSS의 다섯 가지 일반적인 페이지 레이아웃

CSS의 다섯 가지 일반적인 페이지 레이아웃

王林
王林앞으로
2020-08-14 17:11:433180검색

CSS의 다섯 가지 일반적인 페이지 레이아웃

공개 스타일 부분 코드:

(권장 튜토리얼: CSS 튜토리얼)

    html * {
      margin: 0;
      padding: 0;
    }
    .layout {
      margin-bottom: 20px;
    }
    .layout article {
      width: 100%;
     }
    .layout article > div {
      min-height: 100px;
    }
    .layout article .left {
      width: 300px;
      background: red;
    }
    .layout article .center {
      background: orange;
    }
    .layout article .right {
      width: 300px;
      background: blue;
    }

float 레이아웃

  <!-- 浮动布局 -->
  <section class="layout float">
    <style>
      .layout.float .left {
        float: left;
      }
      .layout.float .right {
        float: right;
      }
    </style>
    <article class="left-center-right">
      <div class="left"></div>
      <div class="right"></div>
      <div class="center">
        <h2>这是float布局</h2>
        <p>这是一段文字</p>
        <p>这是一段文字</p>
      </div>
    </article>
  </section>

절대 레이아웃

 <!-- 定位布局 -->
  <section class="layout absolute">
    <style>
      .layout.absolute .left-center-right > div {
        position: absolute;
      }
      .layout.absolute .left {
        left: 0;
      }
      .layout.absolute .center {
        left: 300px;
        right: 300px;
      }
      .layout.absolute .right {
        right: 0;
      }
    </style>
    <article class="left-center-right">
      <div class="left"></div>
      <div class="center">
        <h2>这是absolute布局</h2>
        <p>这是一段文字</p>
        <p>这是一段文字</p>
      </div>
      <div class="right"></div>
    </article>
  </section>

flex 레이아웃

  <!-- flex布局 -->
  <section class="layout flex">
    <style>
      .layout.flex {
        margin-top: 140px;
      }
      .layout.flex .left-center-right{
        display: flex;
      }
      .layout.flex .center {
        flex: 1;
      }
    </style>
    <article class="left-center-right">
      <div class="left"></div>
      <div class="center">
        <h2>这是flex布局</h2>
        <p>这是一段文字</p>
        <p>这是一段文字</p>
      </div>
      <div class="right"></div>
    </article>
  </section>

테이블 레이아웃

  <!-- table布局 -->
  <section class="layout table">
    <style>
      .layout.table .left-center-right {
        display: table;
        height: 100px;
      }
      .layout.table .left-center-right > div{
        display: table-cell;
      }
    </style>
    <article class="left-center-right">
      <div class="left"></div>
      <div class="center">
        <h2>这是table布局</h2>
        <p>这是一段文字</p>
        <p>这是一段文字</p>
      </div>
      <div class="right"></div>
    </article>
  </section>

grid

아아아아

위 내용은 CSS의 다섯 가지 일반적인 페이지 레이아웃의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 csdn.net에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제