首页 建站教程 WEB前端 正文

自定义select下拉框

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <!--<link rel="stylesheet"&...
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <!--<link rel="stylesheet" href="bootstrap.css"/>-->
    <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
    <!--<script src="Jquery-1.11.3.js"></script>-->
    <script src="http://code.jQuery.com/jquery-1.8.0.min.js"></script>
    <style>
        ul,li,ol,li{
            list-style:none;
            margin:0;padding:0;
        }
        a,a:link,a:hover,a:visited {
            text-decoration: none;
            color: #333;
            cursor: pointer;
        }
        .dk_toggle:hover{
            color: #00a2d2;
        }
        .fg-text{
            width:110px;
            float: left;
            line-height: 34px;
            text-align: right;
            padding-right: 5px;
            margin-bottom: 0;
            font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
            font-size: 13px; font-weight: normal;}
        .fg-input{
            margin-left:110px;
            position: relative;
        }
        .dk_toggle{
            width:100%;
            border: 1px solid #ccc;
            border-radius: 5px;
            display:inline-block;
            font-size:14px;
            color:#333;
            padding:7px 10px;}
        .dk_toggle:after{
            border-top:5px solid #4B4B4B;
            border-right:5px solid transparent;
            border-left: 5px solid transparent;
            content: "";
            position: absolute;
            right:15px; top:45%;
        }
        .dk_option{
            position:absolute;
            top:32px;
            width:100%;
            border: 1px solid #8c8c8c;
            border-bottom-left-radius: 5px;
            border-bottom-right-radius: 5px;
            border-top-color:#ddd;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            z-index: 100;background: #FFFFFF}
        .dk_option ul li{
            width:100%;
            padding:8px 10px;
        }
        .dk_hover{
            background: #00a2d2
        }
        .hide{
            display: none
        }
    </style>
</head>
<body>
    <div class="form-group col-md-6">
        <label>项目列表:</label>
        <div>
            <a href="#">请选择</a>
            <div class="dk_option hide" >
                <ul>
                    <li>
                        <a href="#">请选择</a>
                    </li>
                    <li>
                        <a href="#">项目一</a>
                    </li>
                    <li>
                        <a href="#">项目二</a>
                    </li>
                    <li>
                        <a href="#">项目三</a>
                    </li>
                    <li>
                        <a href="#">项目四</a>
                    </li>

                </ul>
            </div>
        </div>
    </div>
    <script>
        $(function(){
           $("a,input,button").focus(function(){this.blur()});
           var dk_option = $(".dk_option");
           var dk_toggle = $(".dk_toggle");
            dk_toggle.click(function(event){
                event.preventDefault();
               if(dk_option.hasClass("hide")){
                   dk_option.removeClass("hide");
               }else{
                   dk_option.addClass("hide")
               }
           });
            dk_option.on("mouSEOver","li",function(){
                $(this).addClass("dk_hover")
                       .siblings("li")
                       .removeClass("dk_hover")
            });
            dk_option.on("click","li",function(){
                dk_toggle.html( $(this).children("a").html())
                              .next(".dk_option")
                              .addClass("hide");
            })
       });
    </script>
</body>
</html>


打赏
海报

本文由优美主题原创或收集发布

转载请注明本文地址:http://www.umtheme.com/web/35.html

相关推荐

Js简单实现复制指定内容到粘贴板

Js简单实现复制指定内容到粘贴板

通过以下代码,点击按钮可直接把input或者textarea里的值复制到粘贴板里,此方法不依赖jquery框架,实现简单粗暴希望对大家有所帮助。<!DOCTYPE html>...
WEB前端 2021.04.14 0 225
Js实现双击鼠标自动滚动页面效果

Js实现双击鼠标自动滚动页面效果

主要介绍了Js实现双击鼠标自动滚动页面的示例代码,在特定的页面也许可以用的的上例如小说或一些资讯类型的网站,需要的朋友可以试一试。操作比较简单把以下代码加在网站的页面中,就可以实现双击鼠标实现自动滚屏...
WEB前端 2021.03.15 0 347
如何通过css3给自己网站logo添加闪光效果

如何通过css3给自己网站logo添加闪光效果

通过css3给自己网站logo添加闪光效果,感觉效果还不错,可以提升用户对网站或企业的品牌印象。具体实现方法如下:找到自己网站logo外面层的盒子(元素),并给该元素添加以下css代码/*首先我们需...
WEB前端 2021.01.14 2 723
发布评论

ainiaobaibaibaibaobaobeishangbishibizuichiguachijingchongjingdahaqiandaliandangaodw_dogedw_erhadw_miaodw_tuzidw_xiongmaodw_zhutouganbeigeiliguiguolaiguzhanghahahahashoushihaixiuhanheixianhenghorse2huaixiaohuatonghuaxinhufenjiayoujiyankeaikeliankouzhaokukuloukunkuxiaolandelinileimuliwulxhainiolxhlikelxhqiuguanzhulxhtouxiaolxhwahahalxhzanningwennonuokpinganqianqiaoqinqinquantouruoshayanshengbingshiwangshuaishuijiaosikaostar0star2star3taikaixintanshoutianpingtouxiaotuwabiweifengweiquweiwuweixiaowenhaowoshouwuxiangjixianhuaxiaoerbuyuxiaokuxiaoxinxinxinxinsuixixixuyeyinxianyinyueyouhenghengyuebingyueliangyunzanzhajizhongguozanzhoumazhuakuangzuohenghengzuoyi
感谢您的支持