久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      CSS中常見的布局有哪些?

      CSS中常見的布局有:1、水平居中,內(nèi)聯(lián)元素水平居中、塊級(jí)元素水平居中和多塊級(jí)元素水平居中;2、垂直居中,單行內(nèi)聯(lián)元素垂直居中和多行元素垂直居中;3、利用flex布局;4、單列布局;5、兩列布局。

      CSS中常見的布局有哪些?

      本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。

      1、水平居中:

      內(nèi)聯(lián)元素水平居中

      利用 text-align: center 可以實(shí)現(xiàn)在塊級(jí)元素內(nèi)部的內(nèi)聯(lián)元素水平居中。此方法對(duì)內(nèi)聯(lián)元素(inline), 內(nèi)聯(lián)塊(inline-block), 內(nèi)聯(lián)表(inline-table), inline-flex元素水平居中都有效。

      核心代碼:

      .center-text {   text-align: center; }

      塊級(jí)元素水平居中

      通過把固定寬度塊級(jí)元素的margin-left和margin-right設(shè)成auto,就可以使塊級(jí)元素水平居中。

      核心代碼:

      .center-block {   margin: 0 auto; }

      多塊級(jí)元素水平居中

      利用inline-block

      如果一行中有兩個(gè)或兩個(gè)以上的塊級(jí)元素,通過設(shè)置塊級(jí)元素的顯示類型為inline-block和父容器的text-align屬性從而使多塊級(jí)元素水平居中。

      核心代碼:

      .container {     text-align: center; } .inline-block {     display: inline-block; }

      2、垂直居中

      單行內(nèi)聯(lián)(inline-)元素垂直居中

      通過設(shè)置內(nèi)聯(lián)元素的高度(height)和行高(line-height)相等,從而使元素垂直居中。

      核心代碼:

      #v-box {     height: 120px;     line-height: 120px; }

      多行元素垂直居中

      利用表布局(table)

      利用表布局的vertical-align: middle可以實(shí)現(xiàn)子元素的垂直居中。

      核心代碼:

      .center-table {     display: table; } .v-cell {     display: table-cell;     vertical-align: middle; }

      3、利用flex布局(flex)

      利用flex布局實(shí)現(xiàn)垂直居中,其中flex-direction: column定義主軸方向?yàn)榭v向。因?yàn)閒lex布局是CSS3中定義,在較老的瀏覽器存在兼容性問題。

      核心代碼:

      .center-flex {     display: flex;     flex-direction: column;     justify-content: center; }

      4、單列布局

      主要有兩種:

      – header, content, footer寬度相同,有一個(gè)max-width

      – header和footer占滿瀏覽器100%寬度,content有一個(gè)max-width

      第一種

      <header style="background-color: red; width: 600px; margin: 0 auto;">頭部</header> <main style="background-color: green; width: 600px; margin: 0 auto;">內(nèi)容</main> <footer style="background-color: yellow; width: 600px; margin: 0 auto;">尾部</footer>

      第二種:

      <header style="background-color: red;">頭部</header> <main style="background-color: green; width: 600px; margin: 0 auto;">內(nèi)容</main> <footer style="background-color: yellow;">尾部</footer>

      5、兩列布局

      float + margin

      用float將邊欄與主要內(nèi)容拉到一行,然后設(shè)置主要內(nèi)容的margin。

      <main style="background-color: red;">   <aside style="background-color: yellow; float: left; width: 50px;">邊欄</aside>   <section style="background-color: green; margin-left: 50px;">主要內(nèi)容</section> </main>

      推薦學(xué)習(xí):css視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)