用CSS去掉两个div中间的空白

如题所述

<!-- 这样试试 --><font face="Arial, Helvetica, sans-serif"></font><html>
<head>
<title>1x</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body
.table{
white-space:nowrap;
position:relative;
width:1003px;
height:auto;
border:none;
z-index:auto}.mdiv{
width:1003px;
height:auto;
overflow:hidden;
clear:both;
}.left{
float:left;
width:100px;
height:914px;
overflow:hidden;
clear:left;
}.right{
float:right;
width:100px;
height:914px;
overflow:hidden;
clear:right;
}.middle{
float:left;
width:803px;
height:914px;
}.floor{
width:1003px;
height:auto}
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (1x.psd) --><div class="table">
<!--顶层-->
<div class="mdiv"><img src="images/1x_01.gif" class="1x_01" width="1003px"></div>
<!--中间-->
<div class="table"><img src="images/1x_09.gif" width="1003px" height="9" alt=""></div>
<div class="left"><img src="images/1x_02.gif" width="100px" height="914" alt=""></div>
<div class="middle"><img src="images/1x_04.gif" width="803" height="379" alt=""></div>
<div class="right"><img src="images/1x_05.gif" width="100px" height="914" alt=""></div>
<!--底层-->
<div class="floor"><img src="images/1x_23.gif" width="1003px"></div>
</div>
<!-- End ImageReady Slices -->
</body>
</html>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-01-06

1.如果是将div编程了inline-block后,之间是有间隙的。这个没有办法修改的。

2.如果希望两个div紧邻着,可以使用浮动和定位。

下面是简单的例子,进攻参考:

浮动的方式:
<style>
 div {width:100px; height:100px; backgorund:#ccc; float:left;}
</style>
<body>
 <div></div>
 <div></div>
</body>

定位的方式
<style>
 div {width:100px; height:100px; backgorund:#ccc; position:absolute; top:0; 
     left:0;}
 .d2 {left:100px;}
</style>
<body>
 <div></div>
 <div class="d2"></div>
</body>

第2个回答  2013-03-29
设置两个div 的margin 和padding值都为0;这样就可以
第3个回答  2013-03-28
这得看具体代码,div之间有空白可能是div的margin属性搞的
第4个回答  2013-03-28
<div style="margin:0px">
</div>