css中设置外边距(margin)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>外边距</title>
        <!--外边距--margin:盒子与和盒子之间的距离
          1.相连子元素外边距会传递给父元素--打断相连
          2.相连兄弟元素如果有相连的外边距会发生重叠,会取较大的那一个
          <div></div>--块状元素
         -->

        <style type="text/css">
            .box1{
            width: 200px;
            height: 100px;
            .box2{

            }
            .box3{

            }
        </style>
    </head>
    <body>
        <div class="box1">
         <div class="box3">

         </div> 
        </div>
        <div class="box2">

        </div>
    </body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_43090158/article/details/82317853
今日推荐