高度不确定时而且不使用盒子模型等的情况下让其居中

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;padding: 0;
        }
        html,body{
            width: 100%;
            height: 100%;
        }
    .abc{
        position: fixed;
        top:50%;
        right:10px;
         transform: translate(0,-50%); 
        width:400px;
        height: 30%;
        border-radius: 3px;
        background: #000;
    }
    </style>
</head>
<body>
    <div class="abc"></div>
</body>
</html>

关键在于用css就阔以让其居中

猜你喜欢

转载自blog.csdn.net/qq_36264495/article/details/79202228