怎样使两个DIV上下之间没间距?

来源:百度知道 编辑:UC知道 时间:2024/06/09 20:40:31
<!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>
</head>

<body>
<div style=" width:691px; height:50px;border-top:0px; ">
<img src="img/jiaju_01.jpg" >
</div>
<div style="background:url(img/jiaju_04.gif) repeat-y left top; width:691px; height:50px; border-top:0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; text-align:center"; margin:auto">
</di

使两个DIV上下之间没间距方法:
如果想上下两个DIV间有距离的话,只需设定div中的margin属性即可,本例中div属性对全局DIV块都适用,代码如下:
<!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">

<style type="text/css">
<!--设置DIV块的边界为5px-->
div{margin:5px;border:0;padding:0;}
#Box1{
width:200px;
height:72px;
background-color:#666;
}
#Box2{
width:200px;
height:72px;
background-color:#F0F;
}
</style>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>让上下两个DIV块之间没有距离</title