Div+CSS中的空白的一行是怎么出现的啊~

来源:百度知道 编辑:UC知道 时间:2024/06/06 01:36:42
html文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link href="css2.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="container">页面层容器
<div id="Header">页面头部</div>
<div id="PageBody">页面主体
<div id="Sidebar">侧边栏</div>
<div id="MainBody">主体内容</div>
<

1,设置margin-top:0px;margin-bottom:0px;可以把顶部和底部设置为不空行。你这里头部并没有空一行,而是你没有加背景色,并且加了文字。
2
<div id="PageBody">,则用#PageBody
id用(#)PageBody
class用点号(.)PageBody
如果是<div class="PageBody">,那就用.PageBody

1/*页面头部*/
#Header {width:800px;margin:0 auto;height:100px;background:#FFCC99}

/*页面底部*/
#Footer {width:800px;margin:0 auto;height:50px;background:#00FFFF}

看上面的两个代码中的height:100px和height:50px就是空白出现的原因,如果设为0就没有空白了
2.CSS引用ID格式:#+ID名

设置margin-top:0px;margin-bottom:0px;可以把顶部和底部设置为不空行。

出现一行有很多方法!
最简单的直接设置高
height:50px;

添加了换行标签 <br />,可能是