让一个div在不同的显示器中永远居中

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        .center_box{
            width: 80%;
            height: 50%;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
    </style>
</head>
<body>
    <div class="center_box" style="border: 1px solid #f00; ">hhhhh</div>
</body>
</html>

 

posted @ 2016-03-03 18:15  ifIhaveWings  阅读(300)  评论(0编辑  收藏  举报