我不太确定我在这里做错了什么。当某人悬停在导航项目上时(本例中为“产品”链接),我需要一个标准的下拉导航块。我没有使用无序列表,只是链接。我设法以合适的格式将所有元素放在正确的位置,看起来不错。唯一的问题是,当我将鼠标悬停在主菜单按钮上时,我无法看到子菜单?无法弄清楚为什么,这对我来说很好。我预览谷歌浏览器下拉菜单(悬停)
<!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'。 –