<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>二级菜单</title>
<style>
*{
margin:0;
padding: 0;
box-sizing:border-box;
}
body{
background: #34495E;
}
#box{
position: relative;
background: #3C3C3C;
width: 200px;
height: 370px;
}
ul{
list-style: none;
width: 200px;
text-align: center;
font-size: 26px;
color: #fff;
padding-top: 0.1px;
}
li{
background: rgba(77,77,77,0.5);
margin:5px auto;
width: 200px;
height: 40px;
line-height: 40px;
}
li:hover{
background: #FFCE3E;
color: #000;
}
#concent{
position: absolute;
top:0;
left: 200px;
display: "none";
/*background: #FFF;*/
background: rgba(77,77,77,0.9);
border-radius: 0 20px 20px 0;
color: #fff;
width: 700px;
height: 370px;
}
#concent div{
display: none;
text-align: center;
font-size: 40px;
}
</style>
</head>
<body>
<div id = "box">
<ul>
<li>加电</li>
<li>手机</li>
<li>彩电</li>
<li>购物</li>
<li>加电</li>
<li>手机</li>
<li>彩电</li>
<li>购物</li>
</ul>
<div id = "concent" style="display:none">
<div class="div">加电页面</div>
<div class="div">手机页面</div>
<div class="div">彩电页面</div>
<div class="div">购物页面</div>
<div class="div">加电页面</div>
<div class="div">手机页面</div>
<div class="div">彩电页面</div>
<div class="div">购物页面</div>
</div>
</div>
</body>
<script>
var lis = document.querySelectorAll("li");
var divs = document.querySelectorAll(".div");
var box = document.querySelector("#box");
var concent = document.querySelector("#concent");
box.onmouseover = function (){
for (var i = 0; i < lis.length; i++) {
lis[i].mm = i;
lis[i].onmouseover = function(){
for (var j = 0; j < divs.length; j++) {
divs[j].style.display = "none";
}
divs[this.mm].style.display = "block";
}
concent.style.display = "block";
}
}
box.onmouseout = function(){
concent.style.display = "none";
}
</script>
</html>
网友评论