css的margin与padding练习

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

</body>
</html>
原文地址:https://www.cnblogs.com/startl/p/12167668.html