码迷,mamicode.com
首页 > 其他好文 > 详细

9月23日 子菜单下拉

时间:2016-09-23 12:44:27      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

<style type="text/css">
*{ margin:0px auto; padding:0px}
#menu{ width:700px; height:40px; border:1px solid #999; margin-top:30px}
.list{ width:100px; height:40px; text-align:center; line-height:40px; vertical-align:middle; font-size:16px; font-family:微软雅黑; float:left}
.list:hover{ cursor:pointer; color:white}
.ziwai{width:0px; height:0px;position:relative; float:left; top:40px; left:-100px}
.zi{ width:100px; height:100px; display:none }
</style>

</head>

<body>

<div id="menu">
<div class=‘list‘ onmouseover="Show(‘z1‘)" onmouseout="YinCang()">首页</div>
<div class="ziwai" >
<div class="zi" id="z1"></div>
</div>
<div class=‘list‘ onmouseover="Show(‘z2‘)" onmouseout="YinCang()">产品介绍</div>
<div class="ziwai" >
<div class="zi" id="z2"></div>
</div>
<div class=‘list‘ onmouseover="Show(‘z3‘)" onmouseout="YinCang()">公司简介</div>
<div class="ziwai" >
<div class="zi" id="z3"></div>
</div>
<div class=‘list‘ onmouseover="Show(‘z4‘)" onmouseout="YinCang()">联系我们</div>
<div class="ziwai" >
<div class="zi" id="z4"></div>
</div>
<div class=‘list‘ onmouseover="Show(‘z5‘)" onmouseout="YinCang()">新闻动态</div>
<div class="ziwai" >
<div class="zi" id="z5"></div>
</div>
</div>

</body>
<script type="text/javascript">

function Show(id)
{
//让所有的子菜单隐藏
var attr = document.getElementsByClassName("zi");

for(var i=0; i<attr.length;i++)
{
attr[i].style.display = "none";
}

//让和该菜单关联的子菜单显示
document.getElementById(id).style.display = "block";
}

function YinCang()
{
var attr = document.getElementsByClassName("zi");

for(var i=0; i<attr.length;i++)
{
attr[i].style.display = "none";
}
}

</script>
</html>

9月23日 子菜单下拉

标签:

原文地址:http://www.cnblogs.com/xiaofox0018/p/5899441.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!