css总结

css_居中:transform

2018-11-27  本文已影响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>
上一篇 下一篇

猜你喜欢

热点阅读