• jquery的下拉选择框


    html代码:

    <body>
    <div class="select">
    <p data-value="所以选项">用户中心</p>
    <ul>
    <li data-value="个人资料" >个人资料</li>
    <li data-value="密码修改">密码修改</li>
    <li data-value="我的订单">我的订单</li>
    <li data-value="退出">退出</li>
    </ul>
    </div>
    </body>

    css代码:

    <style>
    .select{
    120px;
    height: 40px;
    background: #ff8;
    margin: 0px auto;
    position: relative;
    cursor: pointer;
    }
    .select::after{
    content: "";
    display: block;
    10px;
    height: 10px;
    border-left: 1px solid #D0D0D0;
    border-bottom: 1px solid #D0D0D0;
    top: 12px;
    right: 12px;
    position: absolute;
    transform: rotate(-46deg);
    transition: all .3s ease-in;
    }
    .select p{
    120px;
    line-height: 40px;
    font-size: 16px;
    font-family: "microsoft yahei";
    color: #666666;
    padding: 0px 15px;
    }
    .select ul{
    100px;
    display: block;
    font-size: 16px;
    background: #FFFFFF;
    position: absolute;
    top: 40px;
    left: 0px;
    max-height: 0px;
    overflow: hidden;
    transition: max-height .3s ease-in;
    }
    .select ul li{
    100%;
    height: 30px;
    line-height: 30px;
    padding: 0px 15px;
    list-style: none;
    color: #666666;
    }
    .select ul li.Selected{
    background: yellowgreen;
    color: #FFFFFF;
    }
    .select ul li:hover{
    background: #D0D0D0;
    }
    @-webkit-keyframes slide-down{
    0%{transform: scale(1,0);}
    25%{transform: scale(1,1.2);}
    50%{transform: scale(1,0.85);}
    75%{transform: scale(1,1.05);}
    100%{transform: scale(1,1);}
    }

    .select.open ul{
    max-height: 250px;
    transform-origin: 50% 0;
    -webkit-animation: slide-down .5s ease-in;
    transition: max-height .2s ease-in;
    }
    .select.open::after{
    transform: rotate(134deg);
    transition: all .3s ease-in;
    top: 18px;

    }
    </style>

    js代码:

    <script>
    $(function(){
    $(".select p").click(function(e){
    $(".select").toggleClass('open');
    e.stopPropagation();
    });

    $(".content .select ul li").click(function(e){
    var _this=$(this);
    $(".select > p").text(_this.attr('data-value'));
    _this.addClass("Selected").siblings().removeClass("Selected");
    $(".select").removeClass("open");
    e.stopPropagation();
    });

    $(document).on('click',function(){
    $(".select").removeClass("open");
    })

    });
    </script>

  • 相关阅读:
    sql日期操作
    用户活跃状态模型
    R基于Bayes理论实现中文人员特性的性别判定
    python的一点小常识
    [工作技能]SVN
    北大计算所词性标注集简表
    c++ boost 汉字和模式串混用的例子
    SVN文本文件报二进制属性的问题
    我的R代码备份
    FaceBook Twitter实习生简历求内推
  • 原文地址:https://www.cnblogs.com/tuhailin/p/5627239.html
Copyright © 2020-2023  润新知