zoukankan      html  css  js  c++  java
  • margin负——块元素垂直、水平居中

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>垂直居中</title>
        <style>
            .boxBig {
                /* 子绝父相 */
                position: relative;
                 600px;
                height: 700px;
                background-color: gray;
            }
            
            .box {
                position: absolute;
                /* 水平居中 2行——自己width的一半*/
                left: 50%;
                margin-left: -150px;
                /* 垂直居中 2行——自己height的一半*/
                top: 50%;
                margin-top: -150px;
                 300px;
                height: 300px;
                background-color: pink;
            }
        </style>
    </head>
    
    <body>
        <div class="boxBig">大盒子
            <div class="box">盒子</div>
        </div>
    </body>
    
    </html>
    
  • 相关阅读:
    day4
    day3
    day2
    day1
    结对开发
    开课博客
    个人课程总结
    学习进度条-第八周
    学习进度条-第七周
    Fooks 电梯演讲
  • 原文地址:https://www.cnblogs.com/icemiaomiao3/p/14128110.html
Copyright © 2011-2022 走看看