CSS之绝对定位的居中对齐

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绝对定位的居中对齐</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color: #2288f6;
            position: absolute;
            left: 50%;
            margin-left: -100px;
            top: 50%;
            margin-top: -100px;
        }
    </style>
</head>
<body>
<div></div>
</body>
</html>

 

posted @ 2019-04-06 22:57  showTimehzy  阅读(174)  评论(0编辑  收藏  举报