不定宽高盒子水平垂直居中的写法

Posted on 2015-09-28 09:55  !sylar  阅读(419)  评论(0编辑  收藏  举报

1. width: 1200px;
    height: 600px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
2. width: 1200px;
    height: 600px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin:-300px 0 0 -600px;