-1
我想用CSS建立導航菜單欄,出了點問題,但無法確定它是什麼。
的HTML代碼爲: -
設計下拉菜單時,下面的CSS代碼出現錯誤?
<!DOCTYPE html>
<html>
<head>
<title>CSS3 drop down</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
<ul> <!--sub_menu of About to be build-->
<li><a href="#">Sub 1</a></li>
<li><a href="#">Sub 2</a></li>
<li><a href="#">Sub 3</a></li>
</ul>
<li><a href="#">Cases</a></li>
<ul> <!--sub_menu of Cases to be build-->
<li><a href="#">Sub 4</a></li>
<li><a href="#">Sub 5</a></li>
<li><a href="#">Sub 6</a></li>
</ul>
<li><a href="#">Policy</a></li>
<li><a href="#">History</a></li>
</ul>
</body>
</html>
的CSS代碼是這樣的: -
.menu,
.menu ul,
.menu li,
.menu a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
/*Determing the margin ,,centering the drop down menu on the page*/
ul.menu {
margin : 150px auto 0 auto;
}
/* menu */
.menu {
height : 60px;
width : 550px;
background: #e3e3e3;
border-radius: 10px;
}
.menu li {
display: block;
height: 60px;
float: left;
list-style: none;
position: relative;
}
/*All the links to be displayed*/
.menu li a {
display: block;
text-decoration: none;
font-weight: bold;
color: black;
font-size: 17px;
padding: 0 18px;
margin: 10px 0;
line-height: 50px;
border-left: 1px groove #d6d6d6;
border-right: 1px groove #d6d6d6;
transition: color.8s;
}
.menu li:first-child a { border-left:none; }
.menu li:last-child a { border-right:none; }
/*changing color on hover*/
.menu li:hover > a {
color: red;
}
/*Sub menu*/
.menu ul {
/*opacity: 0;*/
position: absolute;
top: 60px;
background-color: red;
}
PLZ給出明確解釋什麼r把主要問題.. !!!!!同時使