"Select"
Bootstrap 3.3.0 Snippet by adarwash2012

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="wrap-select"> <div id="dd" class="wrapper-dropdown-3"> <span>Выберите категорию...</span> <ul class="dropdown"> <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> <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>
/*########### COMMON STYLE ##############*/ * {margin: 0; padding: 0;} body {margin: 30px; font: 13px/1.5 "Trebuchet MS", Tahoma, Arial;} a {color: #0094D6;} p {padding: 7px 0;} h1 {font-size: 21px; font-weight: normal; margin: 0 0 30px;} /*#######################################*/ .wrapper-dropdown-3 { /* Size and position */ position: relative; width: 200px; margin: 0 auto; padding: 10px; /* Styles */ background: #fff; border: 1px solid rgba(0,0,0,0.15); box-shadow: 0 1px 1px rgba(50,50,50,0.1); cursor: pointer; outline: none; } .wrapper-dropdown-3:after { content: ""; width: 0; height: 0; position: absolute; right: 15px; top: 50%; margin-top: -3px; border-width: 6px 6px 0 6px; border-style: solid; border-color: #000 transparent; } .wrapper-dropdown-3 .dropdown { /* Size & position */ position: absolute; top: 100%; left: 0; right: 0; padding:0; margin:0; /* Styles */ background: white; border: 1px solid rgba(0,0,0,0.17); font-weight: normal; -webkit-transition: all 0.5s ease-in; -moz-transition: all 0.5s ease-in; -ms-transition: all 0.5s ease-in; -o-transition: all 0.5s ease-in; transition: all 0.5s ease-in; list-style: none; /* Hiding */ opacity: 0; pointer-events: none; } /*.wrapper-dropdown-3 .dropdown:after { content: ""; width: 0; height: 0; position: absolute; bottom: 100%; right: 15px; border-width: 0 6px 6px 6px; border-style: solid; border-color: #fff transparent; } .wrapper-dropdown-3 .dropdown:before { content: ""; width: 0; height: 0; position: absolute; bottom: 100%; right: 13px; border-width: 0 8px 8px 8px; border-style: solid; border-color: rgba(0,0,0,0.1) transparent; }*/ .wrapper-dropdown-3 .dropdown li a { display: block; padding: 10px; text-decoration: none; color: #000; border-bottom: 1px solid #e6e8ea; box-shadow: inset 0 1px 0 rgba(255,255,255,1); -webkit-transition: all 0.3s ease-out; -moz-transition: all 0.3s ease-out; -ms-transition: all 0.3s ease-out; -o-transition: all 0.3s ease-out; transition: all 0.3s ease-out; } .wrapper-dropdown-3 .dropdown li i { float: right; color: inherit; } .wrapper-dropdown-3 .dropdown li:first-of-type a { border-radius: 7px 7px 0 0; } .wrapper-dropdown-3 .dropdown li:last-of-type a { border: none; border-radius: 0 0 7px 7px; } /* Hover state */ .wrapper-dropdown-3 .dropdown li:hover a { background: #f3f8f8; } /* Active state */ .wrapper-dropdown-3.active .dropdown { opacity: 1; pointer-events: auto; } /* No CSS3 support */ .no-opacity .wrapper-dropdown-3 .dropdown, .no-pointerevents .wrapper-dropdown-3 .dropdown { display: none; opacity: 1; /* If opacity support but no pointer-events support */ pointer-events: auto; /* If pointer-events support but no pointer-events support */ } .no-opacity .wrapper-dropdown-3.active .dropdown, .no-pointerevents .wrapper-dropdown-3.active .dropdown { display: block; } /*#############################*/
function DropDown(el) { this.dd = el; this.placeholder = this.dd.children('span'); this.opts = this.dd.find('.dropdown a'); this.val = ''; this.index = -1; this.initEvents(); } DropDown.prototype = { initEvents : function() { var obj = this; obj.dd.on('click', function(event){ $(this).toggleClass('active'); return false; }); obj.opts.on('click',function(){ var opt = $(this); obj.val = opt.text(); obj.index = opt.index(); obj.placeholder.text(obj.val); }); }, getValue : function() { return this.val; }, getIndex : function() { return this.index; } } $(function() { var dd = new DropDown( $('#dd') ); });

Related: See More


Questions / Comments: