div水平垂直居中

<style>
        html,
        body,
        div {
            margin: 0;
            padding: 0
        }
        
        .bigBox {
            position: relative;
            width: 300px;
            height: 300px;
            background-color: #000;
            margin: 300px auto;
        }
        
        .smallBox {
            width: 100px;
            height: 100px;
            background-color: #ff0000;
            position: absolute;
            left: 50%;
            top: 50%;
            margin-top: -50px;
            margin-left: -50px;
        }
</style>
<body>
   <div class="bigBox">
        <span class="smallBox"></span>
   </div>
</body>
上一篇:三栏布局的七种方案及优缺点对比总结


下一篇:JPQL和SQL的比较