码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-09-16 06:15:40      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

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

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

标签:

原文地址:http://www.cnblogs.com/xiaofinder/p/4811988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!