首页 > 技术文章 > 让一个div在不同的显示器中永远居中

darkterror 2016-03-03 18:15 原文

<!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>

 

推荐阅读