padding对于margin的影响简单介绍_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:27:26
Original
1249 people have browsed it

padding对于margin的影响简单介绍:
可能很多初学者对于padding是否会影响到margin外边距还不太清楚。
只要写段代码测试一下就可以知道了,先看一段代码实例:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">#box{  width:150px;  height:150px;  background-color:green;  padding:10px;}#inner{  width:50px;  height:50px;  background:red;}</style></head><body><div id="box">  <div id="inner"></div></div></body></html>
Copy after login

上面的代码是没有外边距的时候,下面再看加上外边距的情况,代码实例如下:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">#box{  width:150px;  height:150px;  background-color:green;  padding:10px;}#inner{  width:50px;  height:50px;  background:red;  margin-left:10px;}</style></head><body><div id="box">  <div id="inner"></div></div></body></html>
Copy after login

从上面的代码表现可以看出,padding对margin外边距是有影响的。

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

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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!