我不太確定我在這裏做錯了什麼。當某人懸停在導航項目上時(本例中爲「產品」鏈接),我需要一個標準的下拉導航塊。我沒有使用無序列表,只是鏈接。我設法以合適的格式將所有元素放在正確的位置,看起來不錯。唯一的問題是,當我將鼠標懸停在主菜單按鈕上時,我無法看到子菜單?無法弄清楚爲什麼,這對我來說很好。我預覽谷歌瀏覽器下拉菜單(懸停)
<!DOCTYPE html>
<html>
<head>
<title>Food Supply Company</title>
<link href="FoodSupplyStyle.css" rel="stylesheet" text="text/css">
<link href="https://fonts.googleapis.com/css?family=Volkhov:700" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="title">
<h1>Food Supply Company</h1>
</div>
<div class="menunav">
<a href="#" class="Products">Products</a>
<a href="#">About Us</a>
<a href="#">Contacts</a>
</div>
<div class="productsnav">
<a href="#">Fruits</a>
<a href="#">Vegetables</a>
<a href="#">Dry Foods</a>
<a href="#">Spices</a>
</div>
</div>
</body>
</html>
的CSS樣式表
*{
Margin:0;
background-color: aliceblue;
padding:0
}
.container{
width: 900px;
margin:auto;
height:900px;
}
h1{
padding:20px 0px 10px 0px;
background-color:bisque;
text-align: center;
font-family: 'Verdana',sans-serif;
font-weight: 700;
font-size:50px;
letter-spacing: 2px;
color:coral;
text-shadow: 2px 2px brown;
Width: 100%;
background-color:bisque;
}
a{
text-decoration: none;
text-align: center;
font-family: 'verdana', sans-serif;
width:33%;
text-align: center;
list-style: none;
padding: 5px 0px 5px 0px;
background-color: coral;
color: bisque;
box-shadow: 2px 2px 2px rgb(40,0,0);
}
a:hover{
font-family: 'verdana', sans-serif;
background-color: bisque;
color: coral;
}
.menunav a{
display:inline-block;
margin-top:5px
}
.productsnav{
width:33%;
margin-bottom:3px;
}
.productsnav a{
width:100%;
display: none;
margin-top: 5px;
}
.Products:hover .productsnav a{
display:block;
}
最後幾個在CSS代碼是什麼似乎是錯的,但我無法弄清楚究竟是什麼不妥。我已經觀看了一些視頻,並已格式化的CSS代碼以幾種不同的方式顯示子菜單,但我無法弄清楚。
感謝
爲什麼你不使用'ul'或'ol'。 –