猿问

当给大盒子设置margin后,为什么小盒子也会移动,而且移动之后小盒子与大盒子之间的相对位置没有改变?


<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<style type="text/css">

.par{width:180px;height:200px;

border:1px solid red;

margin-left:30px;

margin-top:30px;

}

.son{width:50px;height:50px;

border:1px solid black;

}

.son2{width:50px;height:50px;

border:1px solid green;

}

</style>

</head>

<body>

<div class="par">

<div class="son"></div>

<div class="son2"></div>

</div>

</body>

</html>



独秀烟沙
浏览 1255回答 1
1回答

EnchantF

大盒子和小盒子是一个整体,你去好好看看,什么是外边距什么,什么是内边距
随时随地看视频慕课网APP

相关分类

Html5
CSS3
我要回答