赢在职场-WEB全栈开发-1-7margin

来源:互联网 发布:photoshopcs6 for mac 编辑:程序博客网 时间:2024/05/18 13:22

1-7margin 外边距

<!doctype html>

<html>

    <head>

        <title>抬头</title>

        <meta charset="utf-8">

        

        <style>

            .InternalStyle1

            {

                width:300px;

                height:300px;

                background:green center bottom no-repeat url("dragon.png");

                border: purple 30px solid;

                padding-top: 100px;

                margin-bottom: 30px;//外边距

            }

            

            .InternalStyle2

            {

                width:300px;

                height:300px;

                background:orange center bottom no-repeat url("dragon.png");

                border: brown 60px solid;

                padding-top: 100px;

                margin-top: 60px;//外边句会叠加,注意InternalStyle1InternalStyle2放在一起时只有60px(最大)的边距,而不是相加后的90px

                //margin:top right bottom left;//复合写法

                //margin:top/bottom right/left;

            }

        </style>

        

        

        <link href = "main.css" rel = "stylesheet">

    </head>

    <body>

        <div class = "InternalStyle1">Internal Style1 内部样式1</div>

        <div class = "InternalStyle2">Internal Style2 内部样式2</div>

        

        <div class = "InternalStyle2">

            边距传递

            <div class = "InternalStyle1">

                边距传递:父子级包含时,子级的margintop会传递给父级。

            </div>

        </div>

    </body>

</html>



0 0
原创粉丝点击