欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CSS中使用table-cell法來達到居中效果

WEB開發(fā)者   發(fā)布時間:2015-07-15 17:02:52   作者:佚名   我要評論
這篇文章主要介紹了CSS中使用table-cell法來達到居中效果,文中的示例給出了與之配合的HTML代碼,需要的朋友可以參考下

這種可能是最好的方法,因為高度可以隨內(nèi)容改變,瀏覽器支持也不差。主要缺陷是會產(chǎn)生額外的標(biāo)簽,每一個需要居中的元素需要三個額外的HTML標(biāo)簽。
2015715164003705.jpg (608×401)

HTML:
 

XML/HTML Code復(fù)制內(nèi)容到剪貼板
  1. <div class="Center-Container is-Table">  
  2.   <div class="Table-Cell">  
  3.     <div class="Center-Block">  
  4.     <!-- CONTENT -->  
  5.     </div>  
  6.   </div>  
  7. </div>  

CSS:
 

CSS Code復(fù)制內(nèi)容到剪貼板
  1. .Center-Container.is-Table { display: table; }   
  2. .is-Table .Table-Cell {   
  3.   displaytable-cell;   
  4.   vertical-alignmiddle;   
  5. }   
  6. .is-Table .Center-Block {   
  7.   width: 50%;   
  8.   margin: 0 <span style="width: auto; height: auto; float: none;" id="11_nwp"><a style="text-decoration: none;" mpid="11" target="_blank" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=0&is_app=0&jk=2d6719abf210fdd5&k=auto&k0=auto&kdi0=0&luki=9&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=d5fd10f2ab19672d&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F3058%2Ehtml&urlid=0" id="11_nwl"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">auto</span></a></span>;   
  9. }  

  好處:

    內(nèi)容高度可變
    內(nèi)容溢出則能自動撐開父元素高度
    瀏覽器兼容性好

  同時注意:

    需要額外的HTML標(biāo)簽

相關(guān)文章

最新評論