css的margin与padding练习

waterv 2020-01-08

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>margin</title>    <style>        body{            margin:0px;        }        .div1{            background-color: aqua;            height:300px;            width:300px;            border:1px solid greenyellow;            /*通过margin将100X100小盒子放在300X300大盒子中间*/            padding:200px 0px 0px 200px;        }        .div2{            background-color: blueviolet;            height:100px;            width:100px;            /*通过margin将小盒子放在大盒子中间*/            /*margin:100px;*/        }    </style></head><body><div class="div1">    <div class="div2"></div>    <!--<div class="div2"></div>--></div></body></html>

相关推荐

ganyouxianjava / 0评论 2012-05-31