0 Comments

CSS水平居中和垂直居中多种解决方案(3)

发布于:2013-07-17  |   作者:广州网站建设  |   已聚集:人围观

7、垂直居中和使用text-align水平居中

ExampleSourceCode
广州网站建设,网站建设,广州网页设计,广州网站设计


  1. <divstyledivstyle="float:left;width:275px;height:375px;border:solidred;"> 
  2. <div 
  3. style="height:375px;width:275px;position:relative;  
  4. display:table-cell;vertical-align:middle;"> 
  5. <div 
  6. style="position:static;position:absolute\9;top:50%;"> 
  7. <div 
  8. style="position:relative;top:-50%;text-align:center;"> 
  9. <divstyledivstyle="width:275px;"> 
  10. <divstyledivstyle="width:160px;WORD-WRAP:break-word;TABLE-LAYOUT:fixed;  
  11. word-break:break-all;text-align:left;"> 
  12. div> 
  13. div> 
  14.  
  15. div> 
  16. div> 
  17. div> 
  18. div> 
  19.  

8、垂直居中和使用margin水平居中

ExampleSourceCode


  1. <divstyledivstyle="float:left;width:275px;
  2. height:375px;border:solidred;"> 
  3. <div 
  4. style="height:375px;width:275px;position:relative;  
  5. display:table-cell;vertical-align:middle;"> 
  6. <div 
  7. style="position:static;position:absolute\9;top:50%;"> 
  8. <div 
  9. style="position:relative;top:-50%;"> 
  10.  
  11. <divstyledivstyle="margin:0auto;width:160px;WORD-WRAP:break-word;  
  12. TABLE-LAYOUT:fixed;word-break:break-all;"> 
  13. div> 
  14. div> 
  15. div> 
  16. div> 
  17. div> 
飞机