zoukankan      html  css  js  c++  java
  • 7下拉菜单2

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
        <style>
            * {
                padding: 0;
                margin: 0;
            }
            ul {
                list-style: none;
            }
    
            .wrap {
                width: 330px;
                height: 30px;
                margin: 100px auto 0;
                background-image: url(imgs/bg.jpg);
                padding-left: 10px;
            }
    
            .wrap li {
                float: left;
                width: 100px;
                height: 30px;
                margin-right: 10px;
                position: relative;
            }
    
            .wrap a {
                color: black;
                text-decoration: none;
                display: block;
                width: 100px;
                height: 30px;
                text-align: center;
                line-height: 30px;
                background-image: url(imgs/libg.jpg);
            }
    
            .wrap li ul {
                position: absolute;
                display: none;
            }
        </style>
        <script src="jquery-3.3.1.min.js"></script>
        <script>
            $(document).ready(function () {
                // mouseenter事件 是 鼠标经过时触发的事件
                /*$(".wrap li").mouseenter(function () {
                    $(this).children("ul").show();
                });
    
                $(".wrap li").mouseleave(function () {
                    $(this).children("ul").hide();
                });*/
    
                /*$(".wrap li").hover(function () {
                    //alert("1");
                    $(this).children("ul").show();
                }, function () {
                    $(this).children("ul").hide();
                });*/
    
                /*$(".wrap li").hover(function () {
                    /!*alert("1");*!/
                    var $this = $(this).children("ul");
                    var isShow = $this.css("display");
                    if(isShow === "block") {
                        $this.hide();
                    } else {
                        $this.show();
                    }
                });*/
    
                $(".wrap li").hover(function () {
                    $(this).children("ul").slideToggle();
                });
    
            });
        </script>
    </head>
    <body>
        <div class="wrap">
            <ul>
                <li>
                    <a href="#">一级菜单1</a>
                    <ul>
                        <li><a href="#">二级菜单1</a></li>
                        <li><a href="#">二级菜单2</a></li>
                        <li><a href="#">二级菜单3</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#">一级菜单1</a>
                    <ul>
                        <li><a href="#">二级菜单1</a></li>
                        <li><a href="#">二级菜单2</a></li>
                        <li><a href="#">二级菜单3</a></li>
                    </ul>
                </li><li>
                <a href="#">一级菜单1</a>
                <ul>
                    <li><a href="#">二级菜单1</a></li>
                    <li><a href="#">二级菜单2</a></li>
                    <li><a href="#">二级菜单3</a></li>
                </ul>
            </li>
            </ul>
        </div>
    </body>
    </html>

  • 相关阅读:
    ES6 语法详解(Promise对象(重点))
    ES6 语法详解(形参默认值)
    ES6 语法详解(三点运算符)
    ES6 语法详解(箭头函数(重点))
    ES6 语法详解(简化的对象写法)
    ES6 语法详解(模板字符串)
    ES6 语法详解(变量的解构赋值)
    [刷题] 走迷宫
    [bug] A reference cannot be reassigned, so it must be initialized at the member-initialization-list.
    [Qt] LibreCAD 源码分析
  • 原文地址:https://www.cnblogs.com/alex-xxc/p/9738765.html
Copyright © 2011-2022 走看看