Getting Started in One Second: A Simple Way to Center Horizontally and Vertically with Variable Width and Height

write picture description here

<html>
    <meta charset="UTF-8">
    <body>
        <div class="container">
            <div class="wrap">
                <p>铺设大量智能设备,使用人数众多</p>
                <p>帮助客户快速涨粉,平均每日使用人数超100+</p>
                <p>按100台计算,每天涨粉人数10000+</p>
            </div>
        </div>
        <style>
            .container{
                /*这里只是一个最外层的盒子不是内容重点,重点是下面的wrap*/
                width: 500px;
                height: 500px;
                position: relative;
                background: goldenrod;
            }
            .wrap{
                background: #24FFD3;
                text-align: center;
                position:absolute;
                top:50%;
                left:50%;
                transform:translate(-50%,-50%);
                -webkit-transform:translate(-50%,-50%);
                white-space: nowrap;/*不换行*/
            }
        </style>
    </body>
</html>

The protagonist never has to look back at the explosion, bye!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325648750&siteId=291194637