zoukankan      html  css  js  c++  java
  • jQuery实现类似QQ下拉菜单式的效果

    导读:画图很蛋疼,所以还是使用css做一个。刚学的写的很纠结。希望大牛不要介意。

    效果图:

    全部代码:

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css">
            *
            {
                margin: 0;
                padding: 0;
            }
            body
            {
                font-size: 15px;
                padding: 100px;
            }
            .menu
            {
                500px;
                border-bottom: solid 1px gray;
            }
            .menu h3
            {
                border: solid 1px gray;
                height: 30px;
                line-height: 30px;
                padding-left: 10px;
                padding: 0 5px;
                border-bottom: none;
                cursor: pointer;
               
            }
            .menu p
            {
                border-left: solid 1px gray;
                border-right: solid 1px gray;
                padding: 5px 0;
                padding-left: 5px;
            }
            .changecolor{background-color:red;}
        </style>
        <script src="js/jquery-1.4.2.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $(".menu p:not(:first)").hide();
                $(".menu h3").css("background", "#ccc");
                // $(".menu h3").hover(function () { $(this).addClass("changecolor"); }, function () { $(this).removeClass("changecolor"); });
                // $(".menu h3").click(function () { $(this).css("background", "red").next("p").show().siblings().hide(); });
                $(".menu h3").hover(function () { $(this).css("background-color", "gray").siblings("h3").css("background-color", "#ccc"); })
                $(".menu h3").mouseleave(function () { $(".menu h3").css("background", "#ccc") }); //离开时将其变为原来颜色
                var index = $(".menu h3").index(this);
                $(".menu h3").click(function () { $(this).next("p").slideToggle().siblings("p").slideUp(); });
            });
        </script>
    </head>
    <body>
        <div class="menu">
            <h3>
                我的好友</h3>
            <p>
                周杰伦<br />
                ***</p>
            <h3>
                我的朋友</h3>
            <p>
                李连杰<br />
                本拉登</p>
            <h3>
                陌生人</h3>
            <p>
                比尔盖茨<br />
                阿娇</p>
        </div>
    </body>
    </html>

  • 相关阅读:
    poj 3243 Clever Y(BabyStep GiantStep)
    poj 2417 Discrete Logging
    poj 3481 Double Queue
    hdu 4046 Panda
    hdu 2896 病毒侵袭
    poj 1442 Black Box
    hdu 2815 Mod Tree
    hdu 3065 病毒侵袭持续中
    hdu 1576 A/B
    所有控件
  • 原文地址:https://www.cnblogs.com/luodao1991/p/2826925.html
Copyright © 2011-2022 走看看