div+css設定div模組頁面置中,相容ie6+、ff3.0+、chrome

來源:互聯網
上載者:User

想得到如下的頁面效果,例如用於遮罩層的位置控制:

頁面代碼:

<div class="divOuter">    <div class="divInner">        divInner為頁面內置中顯示的塊    </div></div>

嘗試了多次,最後採用如下方案(不相容ie5.5):
.divOuter  {    position:relative;    margin:0 auto;  /* ie5.5 不支援 */        margin-top:25%; /* 設為25%時,距離上邊距為頁面高度的一半,不太理解,chrom、ff、ie6均如此 */    width:300px;     height:200px;}.divInner  {     position:absolute; top:-50%;    width:300px;    height:200px;     background:#dedede;}


 

 

 

相關文章

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.