绝对定位元素水平居中

.center{  
         position: absolute; /*绝对定位*/  
         width: 500px;  
         height:300px;  
         background: red;  
         margin: 0 auto; /*水平居中*/  
         left: 0; /*此处不能省略,且为0*/  
         right: 0; 
} 

 

posted @ 2017-02-19 22:02  党兴明  阅读(121)  评论(0编辑  收藏  举报