前端学习(1825):前端面试题之封装函数之flex实现居中布局老

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        #wrap {
            width: 500px;
            height: 500px;
            background: grey;

            display: -webkit-box;
            -webkit-box-pack: center;
            -webkit-box-align: center;
        }
        #box{
            width: 200px;
            height: 200px;
            background: deeppink;
        }
    </style>
</head>
<body>
<div id="wrap">
    <div id="box"></div>
</div>
</body>
<script type="text/javascript">
    window.onload = function () {
        var box = document.getElementById('box');


    }
</script>
</html>

运行结果

猜你喜欢

转载自blog.csdn.net/weixin_43392489/article/details/107499769