我在我的網站上有一個導航欄。br無效ul
的HTML:
<nav id="navigation">
<a href="index.html"> <h1>My Cooking Webpage</h1> </a>
<ul>
<li>
<a href="nav/recipes.html" class="right_categories">Recipes</a>
</li>
<li>
<a href="nav/categories.html" class="right_categories">Categories</a>
<ul id="subcategories">
<li>
<a href="#">Item 1</a>
</li>
<li>
<a href="#">Item 2</a>
</li>
<li>
<a href="#">Item 3</a>
</li>
</ul>
</li>
<li>
<a href="nav/about.html" class="right_categories">About Us</a>
</li>
</ul>
</nav>
的CSS:
#navigation {
font-size: 24px;
float: right;
}
#featured-image {
width: 800px;
height: 600px;
}
.breadcrumb {
font-size: 20px;
}
#subcategories {
display: none;
}
nav {
display: block;
position: relative;
}
nav li {
display: block;
margin-right: 10px;
float: right;
}
nav li:hover #subcategories {
display: block;
}
nav a {
color: white;
}
nav ul {
padding: 0px;
list-style-type: none;
}
#featuredtext {
position: relative;
}
#page-background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#wrapper {
position: relative;
z-index: 1;
padding: 10px;
}
#slider_wrapper {
width: 100%;
text-align: center;
}
#navigation {
width: 100%;
}
我DOCTYPE
是HTML5(<!DOCTYPE html>
)是否有幫助。
的問題是,當我將鼠標懸停在「類別」鏈接,下拉框下降橫向而不是縱向。當我在<li>
之間插入<br />
s時,HTML不驗證。
我認爲這是因爲CSS中的float: right;
,儘管我試圖用float: none;
來糾正它。
有沒有辦法讓它降下來垂直而非水平,或者是有沒有<br />
替代。我想通過W3C驗證程序HTML和CSS驗證HTML。
怎麼樣? 'margin'和'padding'是CSS中的兩件事讓我很困惑 – 2012-01-06 19:32:17
Margin爲元素的外部增加了空間。填充添加元素內的空間。 – Scott 2012-01-06 19:33:12
我用'float:none'和一點餘量。謝謝! – 2012-06-13 15:11:22