美文网首页css总结
css_居中:transform

css_居中:transform

作者: 壮壮成长记 | 来源:发表于2018-11-27 16:52 被阅读0次
<style type="text/css">
            .parent {
                width: 600px;
                height: 600px;
                background: #808080;
            }

            .parent {
                position: absolute;
                left: 50%;
                top: 50%;
                transform: translate(-50%, -50%);
            }
            .child{
                width: 50%;
                height: 50%;
                background: #DAA520;
            }
            .child{
                position: absolute;
                left: 50%;
                top:50%;
                transform: translate(-50%,-50%);
            }
        </style>
    </head>
    <body>
        <div class="parent">
            <div class="child"></div>
        </div>
    </body>

相关文章

网友评论

    本文标题:css_居中:transform

    本文链接:https://www.haomeiwen.com/subject/rqfnqqtx.html