<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實(shí)現(xiàn)垂直居中,5種CSS實(shí)現(xiàn)垂直居中的方法

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

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

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

      方法一

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

      Content goes here

      #wrapper {display:table;}

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

      方法二:

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

      因?yàn)橛泄潭ǜ叨龋蛟S你想給 content 指定 overflow:auto,這樣如果 content 太多的話,就會(huì)出現(xiàn)滾動(dòng)條,以免content 溢出。

      Content goes here

      #content {

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

      方法三

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

      Content here

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

      方法四

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

      Content here

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

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

      方法五

      這個(gè)方法使用了一個(gè) position:absolute,有固定寬度和高度的 div。這個(gè) div 被設(shè)置為 top:0; bottom:0;。但是因?yàn)樗泄潭ǜ叨龋鋵?shí)并不能和上下都間距為 0,因此 margin:auto; 會(huì)使它居中。使用 margin:auto;使塊級(jí)元素垂直居中是很簡(jiǎn)單的。

      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>

        • 格尔木市| 扶余县| 皋兰县| 潍坊市| 富民县| 馆陶县| 冀州市| 阿图什市| 米易县| 麦盖提县| 武穴市| 临泉县| 长沙市| 龙江县| 山阴县| 栖霞市| 嘉峪关市| 嘉义县| 松原市| 黎城县| 台南县| 华阴市| 崇礼县| 榕江县| 永德县| 龙海市| 安溪县| 桐柏县| 深泽县| 盐源县| 通山县| 珠海市| 石渠县| 临江市| 稻城县| 西贡区| 巴塘县| 吉首市| 三明市| 湘潭市| 米林县|