在細化我網站的橫幅/導航欄時,我發現了div之間的一些奇怪的間距。這裏有兩個鏈接顯示我在JSFiddle中的問題。 Link 1 |我使用PHP來確定顯示哪些內容,所以我需要兩個來證明這兩個可能性的問題。HTML/CSS奇怪的間距
我花了大約3個小時擺弄代碼,試圖找出發生了什麼,以及如何解決它,但無濟於事。我似乎無法確定是什麼導致了這個問題。
編輯:我發現奇怪的是綠色和黑色邊框之間的差距。
我的代碼(來自的jsfiddle):
鏈接1個HTML:
<div id="banner">
<div id="bannerleft"></div>
<div id="bannercenter">
<div id="nav_content">
<ul>
<li>
<div><a href="../">Home</a>
</div>
</li>
<li>|</li>
<li>
<div><a href="forum">Forums</a>
</div>
</li>
<li>|</li>
<li>
<div><a href="market">Market</a>
</div>
</li>
</ul>
</div>
</div>
<div id="bannerright">
<div id=accountcontent> <span><a href="login">Login</a> | <a href="register">Register</a></span>
</div>
</div>
</div>
鏈路1周的CSS:
#banner {
height: 30px;
width: 100%;
display: table;
margin-bottom: 20px;
}
#bannerleft {
display: table-cell;
text-align: left;
outline-color: black;
outline-style: dashed;
width: 33.33%;
}
#bannercenter {
display: table-cell;
text-align: center;
outline-color: black;
outline-style: dashed;
padding: 0px;
height:30px;
width: 33.33%;
}
#nav_content {
height: 30px;
margin: 0 auto;
padding: 0px;
outline-color: green;
outline-style: dashed;
}
#nav_content ul {
height: 30px;
margin: 0 auto;
padding: 0px;
}
#nav_content ul li {
display: inline-block;
list-style: none;
line-height: 30px;
}
#nav_content ul li div {
height: 30px;
}
#bannerright {
display: table-cell;
text-align: center;
outline-color: black;
outline-style: dashed;
padding: 0px;
height:30px;
width: 33.33%;
}
#accountcontent {
outline-color: green;
outline-style: dashed;
height:30px;
}
鏈路2 HTML:
<div id="banner">
<div id="bannerleft"></div>
<div id="bannercenter">
<div id="nav_content">
<ul>
<li>
<div><a href="../">Home</a>
</div>
</li>
<li>|</li>
<li>
<div><a href="forum">Forums</a>
</div>
</li>
<li>|</li>
<li>
<div><a href="market">Market</a>
</div>
</li>
</ul>
</div>
</div>
<div id="bannerright">
<div id=accountcontent><a href="account"><img id="avatarsmall" src=""/>AccountName</a>
</div>
</div>
</div>
鏈路2 CSS:
#banner {
height: 30px;
width: 100%;
display: table;
margin-bottom: 20px;
}
#bannerleft {
display: table-cell;
text-align: left;
outline-color: black;
outline-style: dashed;
width: 33.33%;
}
#bannercenter {
display: table-cell;
text-align: center;
outline-color: black;
outline-style: dashed;
padding: 0px;
height:30px;
width: 33.33%;
}
#nav_content {
height: 30px;
margin: 0 auto;
padding: 0px;
outline-color: green;
outline-style: dashed;
}
#nav_content ul {
height: 30px;
margin: 0 auto;
padding: 0px;
}
#nav_content ul li {
display: inline-block;
list-style: none;
line-height: 30px;
}
#nav_content ul li div {
height: 30px;
}
#bannerright {
display: table-cell;
text-align: center;
outline-color: black;
outline-style: dashed;
padding: 0px;
height:30px;
width: 33.33%;
}
#accountcontent {
outline-color: green;
outline-style: dashed;
height:30px;
}
#avatarsmall {
height: 30px;
width: 30px;
padding: 0px;
margin: 0px;
}
您認爲什麼奇怪? –
它是在你所指的bannercenter div和navcontent網格之間的底部的差距?這也是由虛線框 – Abhilash
黑色邊框的綠色邊框廣告之間的差距概述,對不起,我應該已經說的很清楚 –