首页 > 其他 > 详细

普通的横向下拉菜单

时间:2016-07-03 21:49:11      阅读:232      评论:0      收藏:0      [点我收藏+]

HTML中的代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="CSS.css" rel="stylesheet" />
    <script src="JS.js"></script>
</head>
<body>
    <ul id="du1">
        <li class="cl1"><div class="div1"></div></li>
        <li class="cl1"><div class="div1"></div></li>
        <li class="cl1"><div class="div1"></div></li>
    </ul>
</body>
</html>

 

CSS中的代码

* {
    margin: 0px;
    padding: 0px;
}

#du1 {
    position: relative;
    top: 100px;
    left: 100px;
    width: 300px;
    height: 50px;
    background-color: aqua;
}

.cl1 {
    position: relative;
    margin-top: 10px;
    width: 80px;
    height: 30px;
    background-color: red;
    margin-left: 15px;
    list-style-type: none;
    float: left;
}

.div1 {
    position: relative;
    margin-top: 32px;
    width: 80px;
    height: 90px;
    background-color: navy;
    display: none;
}

  

JS中的代码

window.onload = function () {
    var lis = document.getElementsByClassName("cl1");
    for (var i = 0; i < lis.length; i++) {
        lis[i].onmouseover = function () {
            var div = this.getElementsByClassName("div1");
            div[0].style.display = "block";
        }
        lis[i].onmouseout = function () {
            var div = this.getElementsByClassName("div1");
            div[0].style.display = "none";
        }
    }
};

 

普通的横向下拉菜单

原文:http://www.cnblogs.com/123lucy/p/5638733.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!