首页 > 其他 > 详细

解决IE中div不居中的问题(尤其IE5)

时间:2015-04-28 17:32:59      阅读:283      评论:0      收藏:0      [点我收藏+]
    最近布局时遇到了一个问题,就是如何设置div居中?通过查找资料终于找到了解决方案,只需要把要居中的div外嵌套一个div,设置其“text-align:center;”,然后设置要居中的div为“margin-left:auto;margin-right:auto;”
提示:若设置后IE5中仍不居中,只需将外层div设置为“width:100%;”,即可解决问题。
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>设置div居中(兼容IE5+)</title> <style type="text/css"> .content{width:100%;height:200px;text-align:center;} .center{width:500px;height:200px;margin-left:auto;margin-right:auto;border:1px #999 dashed;} </style> </head> <body> <div class="content"> <div class="center"></div> </div> </body> </html>
技术分享

 

解决IE中div不居中的问题(尤其IE5)

原文:http://www.cnblogs.com/lizhenli/p/4463149.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!