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;
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>
posted @ 2020-01-08 17:07  Stary_tx  阅读(210)  评论(0编辑  收藏  举报