定位的盒子居中对齐完美写法

1. 代码

    <html>
    
    <head></head>
    <style>
        .box {
             499.9999px;
            height: 400px;
            background: pink;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            /* 走的自己的一半 */
        }
    </style>
    
    <body>
        <div class="box"></div>
    </body>
    
    </html>

2. 效果展示

原文地址:https://www.cnblogs.com/ifme/p/11796718.html