盒模型——外邊距

來源:互聯網
上載者:User

標籤:移動   可見   round   pad   tom   自動   一個   bsp   otto   


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>postion</title>
        <style>
            .box1{
                width:200px;
                height:200px;
                background: greenyellow;
                /*設定邊框*/
                border:3px red solid;
                /*設定內邊距*/
                padding: 20px;
                
                /*
                 *外邊距margin:指的是當前的盒子與其他盒子之間的距離
                 *     它不會影響盒子課可見框的大小,而是會影響盒子的位置
                 *特性:
                 *  1.  4個方向
                 *  margin-top:
                    margin-right:
                    margin-bottom:
                    margin-left:
                    2.由於頁面中的元素都是靠左靠上位置擺放的
                         所以注意:當我們設定上和左外邊距時,會導致盒子自身位置的發生改變
                                            當我們設定下和右外邊距時,會改變其他盒子的位置
                    3.可以設定 負值,負值——反方向移動
                    4.可以設定auto(自動)
                        一般只設定給水平方向,置中顯示
                    原因:
                    只指定:
                    1)水平方向為auto——————最大值
                    2)垂直方向為auto——————0
                    5.margin      
                 */
                /*margin-top:-100px;
                margin-right: 100px;
                margin-bottom: 100px;*/
                margin: 0 auto;/*水平置中*/
                
            }
            .box3{
                width:200px;
                height:200px;
                background: blue;
                
                
            }
            /*建立一個子項目box2來佔滿box1*/
            .box2{
                height:100px;
                width:100px;
                background: yellow;
                margin-left: 120px;
                
                
            }
        </style>
    </head>
    <body>
            <div class="box1">
                <div class="box2">我是box2</div>
            </div>
            <div class="box3">我是box3</div>
        
    </body>
</html>

盒模型——外邊距

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.