table

          層的絕對居中應用

          1、利用負邊距方法,絕對定位使容器相對屏幕絕對居中,此時的被嵌套容器只能為絕對大小。(標準)
          <div style="background:#f00; width:740px; height:340px; left:50%; margin:-170px 0 0 -370px; position:absolute; top:50%;"></div>

          2、老外給出的另類方法,巧妙利用display:inline-block;,IE6.0測試通過。(標準)

          注意height:100%是關鍵,edge與container沒有嵌套關系:

          <style>
          body { margin:0; height:100%;}
          #edge { width:0; height:100%; display:inline-block; vertical-align:middle;}
          #container { text-align:center; width:100%; display:inline-block; vertical-align:middle;}
          </style>

          <!-- required for xhtml1.1 validation only -->
          <span id="edge"></span>
          <span id="container">
             <div style="width:200px; height:50px; background:#f00; line-height:50px;">僅IE6.0環境下實現</div>
          </span>

          還有不介紹了...

          posted on 2008-12-15 11:36 小卓 閱讀(345) 評論(0)  編輯  收藏 所屬分類: html and js

          主站蜘蛛池模板: 东宁县| 鄄城县| 南漳县| 兴仁县| 张北县| 汾阳市| 师宗县| 柳州市| 西贡区| 怀远县| 大同县| 临泉县| 三穗县| 云阳县| 南涧| 宝坻区| 泽库县| 娄烦县| 临夏市| 宣武区| 陇南市| 丹江口市| 饶平县| 白城市| 墨脱县| 金阳县| 娄底市| 通榆县| 大英县| 航空| 茌平县| 闸北区| 开江县| 宁都县| 平乐县| 哈密市| 石河子市| 土默特左旗| 桓台县| 惠水县| 个旧市|