首頁  >  文章  >  web前端  >  CSS中父对象的内边距是否对子对象的外边距造成影响_html/css_WEB-ITnose

CSS中父对象的内边距是否对子对象的外边距造成影响_html/css_WEB-ITnose

WBOY
WBOY原創
2016-06-24 11:36:481136瀏覽

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

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn