欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!

为什么div css网页在FF浏览器中不能水平居中呢?为什么在其它浏览器中网页居中,在火狐浏览器FF中网页不能布局居中解决方法。

FF下面设置容器的左右外补丁为auto就可以了。

在DIVCSS5网站中介绍过很多次网页布局居中的条件,也是为了最大限度兼容各大浏览器。

条件一:对bodytext-align:center内容居中;
条件二:对需要居中的最外层DIVmargin:0 auto即可,通常最外层DIV都是有宽度的。

DIVCSS5完整案例代码:

  1. <!DOCTYPE html> 
  2. <html> 
  3. <head> 
  4. <meta charset="utf-8" /> 
  5. <title>居中</title> 
  6. <style> 
  7. body{ text-align:center} 
  8. .main{ margin:0 auto; width:500px; height:200px; border:1px solid #F00} 
  9. </style> 
  10. </head> 
  11. <body> 
  12. <div class="main">我所在DIV在任意浏览器均布局居中</div> 
  13. </body> 
  14. </html> 

实例截图:

div css布局居中实例截图
html网页布局居中实例截图

 以上案例实现FF浏览器中网页居中。

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/wenji/w743.shtml