JS技术

JavaScript下拉菜单收藏

字号+ 作者: 来源:    2014-11-17 20:00 我要评论( )

JavaScript下拉菜单收藏,阅读JavaScript下拉菜单收藏,!DOCTYPE html PUBLIC

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>JavaScript下拉菜单</title>
    <style type="text/css">
        * {
            padding:0;
            margin:0;
        }
        body {
            font-family:verdana, sans-serif;
            font-size:small;
        }
        #navigation, #navigation li ul {
            list-style-type:none;
        }
        #navigation {
            margin:20px;
        }
        #navigation li {
            float:left;
            text-align:center;
            position:relative;
        }
        #navigation li a:link, #navigation li a:visited {
            display:block;
            text-decoration:none;
            color:#000;
            width:120px;
            height:40px;
            line-height:40px;
            border:1px solid #fff;
            border-width:1px 1px 0 0;
            background:#c5dbf2;
            padding-left:10px;
        }
        #navigation li a:hover {
            color:#fff;
            background:#2687eb;
        }
        #navigation li ul li a:hover {
            color:#fff;
            background:#6b839c;
        }
        #navigation li ul {
            display:none;
            position:absolute;
            top:40px;
            left:0;
            margin-top:1px;
            width:120px;
        }
        #navigation li ul li ul {
            display:none;
            position:absolute;
            top:0px;
            left:130px;
            margin-top:0;
            margin-left:1px;
            width:120px;
        }
    </style>
    <script type="text/javascript">
        function displaySubMenu(li) {
            var subMenu = li.getElementsByTagName("ul")[0];
            subMenu.style.display = "block";
        }
        function hideSubMenu(li) {
            var subMenu = li.getElementsByTagName("ul")[0];
            subMenu.style.display = "none";
        }
    </script>
</head>
<body>
    <ul id="navigation">
        <li onmouseover="displaySubMenu(this)" onmouseout="hideSubMenu(this)">
            <a href="#">栏目1</a>   
            <ul>
                <li><a href="#">栏目1->菜单1</a></li>
                <li><a href="#">栏目1->菜单2</a></li>
                <li><a href="#">栏目1->菜单3</a></li>
                <li><a href="#">栏目1->菜单4</a></li>
            </ul>
        </li>
        <li onmouseover="displaySubMenu(this)" onmouseout="hideSubMenu(this)">
            <a href="#">栏目2</a>   
            <ul>
                <li><a href="#">栏目2->菜单1</a></li>
                <li><a href="#">栏目2->菜单2</a></li>
                <li><a href="#">栏目2->菜单3</a></li>
                <li><a href="#">栏目2->菜单4</a></li>
                <li><a href="#">栏目2->菜单5</a></li>
            </ul>
        </li>
        <li onmouseover="displaySubMenu(this)" onmouseout="hideSubMenu(this)">
            <a href="#">栏目3</a>   
            <ul>
                <li onmouseover="displaySubMenu(this)" onmouseout="hideSubMenu(this)">
                    <a href="#">栏目3->菜单1</a>
                    <ul>
                        <li><a href="#">菜单1->子菜单1</a></li>
                        <li><a href="#">菜单1->子菜单2</a></li>
                        <li><a href="#">菜单1->子菜单3</a></li>
                        <li><a href="#">菜单1->子菜单4</a></li>
                    </ul>
                </li>
                <li><a href="#">栏目3->菜单2</a></li>
                <li onmouseover="displaySubMenu(this)" onmouseout="hideSubMenu(this)">
                    <a href="#">栏目3->菜单3</a>
                    <ul>
                        <li><a href="#">菜单3->子菜单1</a></li>
                        <li><a href="#">菜单3->子菜单2</a></li>
                        <li><a href="#">菜单3->子菜单3</a></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</body>
</html>

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 学习JavaScript之this,call,apply

    学习JavaScript之this,call,apply

    2016-01-28 20:45

  • 轻松学习JavaScript十五:JavaScript之BOM简介 - 连宏伟 - 博客频道 - CSDN.NET 连宏

    轻松学习JavaScript十五:JavaScript之BOM简介 - 连宏伟 - 博客频道

    2015-12-13 11:34

  • 学习Javascript数组_Javascript教程

    学习Javascript数组_Javascript教程

    2015-10-02 09:18

  • 学习javascript应注意的问题_Javascript教程

    学习javascript应注意的问题_Javascript教程

    2015-09-29 13:03

网友点评