2010-10-13 120 views
0

我在两个div之间有一个奇怪的问题,顶部div下面有一个空格,只显示在IE8中。尽管我在家里使用IE8,但我没有看到它,但是在其他地方我也是这样。IE中两个div之间的空格

图片在IE(红色是不应该存在的空间): In IE

在Firefox和其他浏览器它显示优良,如下所示: In FF

<div id="top"> 

<form action="" onsubmit=""> 

    <table > 

    <tr> 

    <td> 
    Name<input type="text" /> 
    </td> 


    <td> 
    Password<input type="password" />    
    </td> 

    <td> 

    </td>    

    </tr> 


    </table> 

    </form> 

</div> 

    <div id="header"> 

    </div> 


#top 
{ 
    margin-right: auto; 
    margin-left: auto; 
    margin-top: 0px; 
    background-color: #000000; 
    top: 0px; 
    text-align: center; 
    font-size: 16px; 
} 
#header 
{ 
    width: 100%; 
    height: 100px; 
    background-color: #336699; 
    margin: 0px; 
    padding: 0px; 
} 

我有试图浮动两个div的,但我似乎无法得到它的工作。

有什么建议吗?由于

+0

您是否尝试过设置margin-bottom:0;在上面? – JohnFx 2010-10-13 15:44:37

+0

是的,已经试过了,谢谢。 – Elliott 2010-10-13 15:46:02

回答

2

将所有表单元素的边距为0px:

form 
{ 
    margin: 0px; 
} 
+0

完美,谢谢。 – Elliott 2010-10-13 16:32:26

0

变化的div的保证金为0px,看看它的工作原理。