純CSS實現上下左右都置中的代碼_經驗交流

來源:互聯網
上載者:User
<style type="text/css"> #box{width:600px; height:400px; border:1px solid red;} #box{position:static; *position:relative; display:table; *display:block; } #box-middle{position:static; *position:absolute; display:table-cell; *display:block; *top:50%; vertical-align:middle; *vertical-align:auto;} #box-inner{position:relative; top:-50%; background-color:blue; margin:0 auto; width:200px; height:100px;} </style> content
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
終於見識了這個變態的IE7,象霧象雨又象風,IE系列的CSS hack: * html它認;Firefox的CSS hack: html>body、#id[id]、html[xmlns] div這樣的東東它也認,教我說它什麼好呢!
最終通過無敵 * 解決了它!
  • 相關文章

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.