CSS中父对象的内边距是否对子对象的外边距造成影响

CSS中父对象的内边距是否对子对象的外边距造成影响:
建议:尽可能的手写代码,可以有效的提高学习效率和深度。
有时候可能有这样的疑问,父对象的内边距padding是否会对子对象的外边距margin产生影响。下面就来通过实例代码的表现来说明这个问题。实例代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style type="text/css">
.parent{
  width:200px;
  height:200px;
  background-color:green;
  padding-left:20px;
}
.children{
  width:50px;
  height:50px;
  background-color:red;
  margin-left:20px;
}
</style>
</head>
<body>
<div class="parent">
  <div class="children"></div>
</div>
</body>
</html>

 由以上代码的表现可以看出,父对象的内边距可以对对子对象的外边距造成影响的。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=4679

更多内容可以参阅:http://www.softwhy.com/divcss/

猜你喜欢

转载自softwhy.iteye.com/blog/2265174