这次作业我们将来实现下图:
主要有导航栏及下拉菜单组成
编写代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
/* border: 1px solid red; */
}
.menu {
background-color: purple;
width: 100px;
height: 50px;
}
.item {
float: left;
width: 100px;
height: 50px;
line-height: 50px;
text-align: center;
color: white;
position: relative;
}
.item:hover {
background-color: red;
}
.container {
width: 720px;
margin: auto;
}
.down_menu>div {
color: black;
}
.down_menu {
background-color: #cccccc;
display: none;
position: absolute;
}
.item:hover>.down_menu {
display: block;
width: 100px;
left: 0px;
top: 50px;
}
</style>
</head>
<body>
<div class="menu">
<div class="container">
<div class="item">游戏1
<div class="down_menu">
<div>游戏下载</div>
<div>游戏交易</div>
<div>游戏外挂</div>
<div>游戏攻略</div>
</div>
</div>
<div class="item">游戏2</div>
<div class="item">游戏3</div>
<div class="item">游戏4</div>
<div class="item">游戏5</div>
<div class="item">游戏6</div>
</div>
</div>
</body>
</html>