让内容上下左右居中

.vert {
    width: 500px;
    height: 200px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -100px;
    margin-left: -250px;
}

内容上下左右居中
上边的margin计算公式为:

 * Width of Element / 2 = Negative Left Margin

* Height of Element / 2 = Negative Top Margin

posted @ 2016-01-18 14:09  那谁家的丫头  阅读(146)  评论(0编辑  收藏  举报