我想中心對齊導航欄中的內容(以便img是導航欄的中心。我知道我有浮動:左;但是如果我不要,(左邊的東西,右邊的東西)會下降到img的底部邊緣,所以我想要的是保持浮動狀態,但是能夠顯示:inline-block或者其他相同的東西。我也想要下拉菜單酒吧爲(左事情)開始在IMG的左側,然後打造出右側。
demo fiddle中心對齊浮動導航欄並從左到右下拉
HTML
<div id="nav">
<div id="container">
<ul>
<li>
<a href="#"> Left thing </a>
<ul>
<li><a href="#"><----- want it to go this way</a>
</li>
<li><a href="#">i want this to start under left thing</a>
</li>
</ul>
</li>
<li>
<img src="http://www.jonathanjeter.com/images/Square_200x200.png" style="height:70px" />
</li>
<li>
<a href="#"> Right thing </a>
<ul>
<li><a href="#">This starts right</a>
</li>
<li><a href="#">And this is right</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
CSS
* {
padding: 0;
margin: 0;
}
#body {
padding: 0;
margin: 0;
font-family: Arial;
font-size: 17px;
}
#nav {
background-color: 72776A;
width: 100%;
position:fixed;
height:50px;
}
#nav ul {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
display:block;
}
#nav ul li {
float:left;
}
#container {
text-align:;
}
#nav ul li:hover {
background-color: #333;
}
#nav ul li a, visited {
color: ACD661;
display: block;
padding: 15px;
text-decoration: none;
}
#nav ul li:hover ul {
display: block;
}
#nav ul ul {
display: none;
position:absolute;
color: red;
border: 1px solid black;
}
#nav ul ul li {
display: block;
}
#nav ul ul li a:hover {
color: #699;
}
它幫助很多,如果你縮進你的代碼。現在很難說出什麼是什麼。 – flowstoneknight 2014-09-02 07:20:00