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>

  • 相关阅读:
    CentOS命令修改系统时间同步
    Redis的两种持久化方式-快照持久化(RDB)和AOF持久化
    Mysql优化_内置profiling性能分析工具
    Samba服务器的安装与配置
    Linux下yum安装MysqL数据库
    CentOS下安装配置cmake
    自定义环形进度条
    教你实现语音识别(基于科大讯飞)
    Eclipse中如何安装和使用GrepCode插件
    如何在代码中动态设置字体大小
  • 原文地址:https://www.cnblogs.com/alex-xxc/p/9738765.html
Copyright © 2011-2022 走看看