Home > Web Front-end > HTML Tutorial > width和padding之间的关系介绍_html/css_WEB-ITnose

width和padding之间的关系介绍_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:27:49
Original
1723 people have browsed it

width和padding之间的关系介绍:
本章节简单介绍一下width和padding之间的关系。
主要的疑惑在于,width到底包不包含padding,其实他们的关系非常的单纯,根本不搭调。
之所以会有很多朋友将其搞混是因为他们将width属性和元素的宽度这两个概念混为一谈了。
width属性值并不一定就是元素的实际宽度,看如下代码实例:

 

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

 

从上面的代码可以看到width就是width,padding就是padding。

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

更多内容可以参阅: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