博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
下拉框样式
阅读量:7140 次
发布时间:2019-06-28

本文共 2475 字,大约阅读时间需要 8 分钟。

  hot3.png

html:

<div class="content">

                        <span>单位名称:</span>
                        <div class="select">
                            <p data-value="-1">请选择</p>
                            <ul class="all-animate">
                                <li data-value="单位#1">单位#1</li>
                                <li data-value="单位#2">单位#2</li>
                                
                            </ul>
                        </div>
                    </div>

css:

/**

 * 下拉列表*/
.content{
    width: 22%;
    display: inline-block;
    margin-bottom: 1rem;
}
.content>span{
    width: 50%;
}
.content .select{
    display: inline-block;
    width: 50%; 
    height: 3rem; 
    line-height: 3rem;
    background: #FFFFFF; 
    position: relative;
    cursor: pointer;
    border: 1px solid #dcdcdc;
    border-radius: 0.5rem;
}
.content .select::after{
    content: "";
    display: block;
    width: 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;
}
.content .select p{
    width: 80%;
    line-height: 3rem; 
    font-size: 1.2rem;
    font-family: "microsoft yahei";
    color: #666666;
    padding: 0px 15px;
}
.content .select ul{
    border: 1px solid #dcdcdc;
    border-radius: 0.5rem;
    width: 100%;
    display: none;
    font-size: 1.2rem;
    background: #FFFFFF;
    position: absolute;
    top: 3rem;
    left: 0px;
    max-height: 0px;
    overflow: hidden;
    z-index: 999;
    transition: max-height .3s ease-in;
}
.content .select ul li{
    width: 100%;
    height: 3rem;
    line-height: 3rem;
    padding: 0px 15px;
    list-style: none;
    color: #666666;
}
.content .select ul li.Selected{
    background: #FF8000;
    color: #FFFFFF;
}
.content .select ul li:hover{
    background: #FF8000;
    color: #FFFFFF;
}
@-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);}
}

.content .select.open ul{

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

js:

/**

 * 下拉列表*/

$(function(){

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

转载于:https://my.oschina.net/lslDn/blog/1538102

你可能感兴趣的文章
route命令详解
查看>>
兵以诈立——我读孙子
查看>>
Nagios报Error: Could not read object configuration data!解决方法
查看>>
Web 服务编程,REST 与 SOAP 为什么选择 REST
查看>>
lamp环境下phpwind,wordpress,discuz论坛的搭建全过程
查看>>
Maven更新包数度慢
查看>>
linux shell 判断 if 脚本
查看>>
软件设计是怎样炼成的(7)——细节决定成败(详细设计)
查看>>
UVA11300 Spreading the Wealth
查看>>
C的一种老写法,没怎么理解,大家看看
查看>>
Linux系统安装如何给磁盘分区
查看>>
TOMCAT日常调整的手记.
查看>>
我的友情链接
查看>>
配置功能: WiFi无线网络配置代理
查看>>
备份服务器为什么不稳定的原因?
查看>>
我的友情链接
查看>>
转载-------我当网络包租公的日子
查看>>
linux下的公式编辑器
查看>>
网卡初始化一般操作
查看>>
linux 实现自动挂载
查看>>