body在默认情况下是具有margin外边距的_html/css_WEB-ITnose

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

body在默认情况下是具有margin外边距的:
这里只是陈述一个事实,那就是body具有外边距在默认情况下。
代码实例如下:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css"> body{  background:blue;}#box{  width:200px;  height:100px;  background:red;  text-align:center;  line-height:100px;}</style></head><body><div id="box">蚂蚁部落</div></body></html>
Copy after login

从上面的代码可以看出,box元素与外围有一定的空隙,再来看一段代码实例:

<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css"> body{  background:blue;  margin:0px;}#box{  width:200px;  height:100px;  background:red;  text-align:center;  line-height:100px;}</style></head><body><div id="box">蚂蚁部落</div></body></html>
Copy after login

上面的代码可以看出,空隙消失,说明body是具有外边距的。
所以在正式些页面之前,通常先重置一下样式属性,具体可以参阅css预重置样式代码一章节。

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

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