<strike id="3tkic"><sup id="3tkic"></sup></strike>

  1. <ul id="3tkic"></ul>
      <b id="3tkic"><legend id="3tkic"></legend></b>
      <b id="3tkic"><meter id="3tkic"></meter></b>

    • <strike id="3tkic"></strike>

      <blockquote id="3tkic"></blockquote>

    • 亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l

      5種方法CSS實現(xiàn)垂直居中,5種CSS實現(xiàn)垂直居中的方法

      2012/3/19 15:13:39   閱讀:2721    發(fā)布者:2721

      使用網(wǎng)站建設(shè)CSS 實現(xiàn)垂直居中并不輕易。我下面說明一下我看到的好的方法和怎么來創(chuàng)建一個好的居中網(wǎng)站。

      利用 CSS 來實現(xiàn)對象的垂直居中有很多不同的方法,比較難的是選擇那個準確的方法。下面我們看一下使對象垂直集中的5種不同方法,以及它們各自的優(yōu)缺點。有些方法在一些瀏覽器中無效。

      方法一

      這個方法把一些 div 的顯示方式設(shè)置為表格,因此我們可以使用表格的 vertical-align property 屬性。

      Content goes here

      #wrapper {display:table;}

      #cell {display:table-cell; vertical-align:middle;}

      方法二:

      這個方法使用絕對定位的 div,把它的 top 設(shè)置為 50%,top margin 設(shè)置為負的 content 高度。這意味著對象必須在 CSS 中指定固定的高度。

      因為有固定高度,或許你想給 content 指定 overflow:auto,這樣如果 content 太多的話,就會出現(xiàn)滾動條,以免content 溢出。

      Content goes here

      #content {

      position:absolute;
      top:50%;
      height:240px;
      margin-top:-120px; /* negative half of the height */
      }

      方法三

      這個方法只能將單行文本置中。只需要簡單地把 line-height 設(shè)置為那個對象的 height 值就可以使文本居中了。

      Content here

      #content {height:100px; line-height:100px;}

      方法四

      這種方法,在 content 元素外插入一個 div。設(shè)置此 div height:50%; margin-bottom:-contentheight;。
      content 清除浮動,并顯示在中間。

      Content here

      #floater {float:left; height:50%; margin-bottom:-120px;}

      #content {clear:both; height:240px; position:relative;}

      方法五

      這個方法使用了一個 position:absolute,有固定寬度和高度的 div。這個 div 被設(shè)置為 top:0; bottom:0;。但是因為它有固定高度,其實并不能和上下都間距為 0,因此 margin:auto; 會使它居中。使用 margin:auto;使塊級元素垂直居中是很簡單的。

      Content here

      #content {

      position:absolute;
      top:0;
      bottom:0;
      left:0;
      right:0;
      margin:auto;
      height:240px;
      width:70%;
      }

      亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l
      <strike id="3tkic"><sup id="3tkic"></sup></strike>

      1. <ul id="3tkic"></ul>
          <b id="3tkic"><legend id="3tkic"></legend></b>
          <b id="3tkic"><meter id="3tkic"></meter></b>

        • <strike id="3tkic"></strike>

          <blockquote id="3tkic"></blockquote>

        • 甘谷县| 宜昌市| 闸北区| 大港区| 同江市| 永德县| 澄江县| 敦煌市| 深州市| 岗巴县| 百色市| 阳原县| 牙克石市| 盖州市| 武山县| 任丘市| 凤山县| 阜城县| 莱西市| 合肥市| 古浪县| 扶沟县| 保德县| 隆化县| 荃湾区| 南华县| 隆德县| 岳普湖县| 三原县| 云浮市| 宝应县| 宜宾县| 六安市| 长岛县| 浏阳市| 莲花县| 霞浦县| 静乐县| 郎溪县| 牡丹江市| 和平区|