Home > Web Front-end > HTML Tutorial > CSS中父对象的内边距是否对子对象的外边距造成影响_html/css_WEB-ITnose

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

WBOY
Release: 2016-06-24 11:36:48
Original
1200 people have browsed it

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>
Copy after login

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

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template