<!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>
一个二级菜单类似与小米首页的菜单0.0就不写注释
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 下面选了最近十年里,十位名人所做的毕业演讲。那么多的故事与经历,其实只想告诉你一件事: 面对迷茫和不确定的未来,我...