css实现垂直水平居中

我们经常用margin:0 auto来实现水平居中,而一直认为margin:auto不能实现垂直居中……实际上,实现垂直居中仅需要声明元素高度和下面的CSS:

.Absolute-Center {  margin: auto;  position: absolute;   top: 0; left: 0; bottom: 0; right: 0;  }  

底部左右居中:

.Absolute-bottom {  margin: auto;  position: absolute;   top: 0; left: 0;  right: 0;  }  

posted @ 2017-10-24 11:34  银河冰枫  阅读(128)  评论(0编辑  收藏  举报