首页 > 其他 > 详细

DIV居中的几种方法

时间:2015-03-24 14:29:57      阅读:135      评论:0      收藏:0      [点我收藏+]

1.

1 body{  
2 text-align:center;  
3 } 

缺点:body内所有内容一并居中

 

2.

.center{
position: fixed;
left: 50%;
}

缺点:需要设置position属性,网页复杂时容易扰乱页面布局

 

3.

1 .center{
2 width:500px;
3 margin: 0 auto;
4 }

缺点:需要设置div宽度

4.

1 .center {  
2   display: -webkit-flex;  
3   -webkit-justify-content: center;  
4   -webkit-align-items: center;  
5  }  

缺点:需要支持Html5

DIV居中的几种方法

原文:http://www.cnblogs.com/ones/p/4362531.html

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