<link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700" rel="stylesheet">
<div class="box">
<h2>Bootstrap Selectpicker Without Bootstrap</h2>
<select class="selectpicker" data-size="4">
<option value="">Select Custom Field</option>
<option value="nickname">nickname</option>
<option value="first_name">first_name</option>
<option value="last_name">last_name</option>
<option value="syntax_highlighting">syntax_highlighting</option>
<option value="_ppm_wp_password_expired">_ppm_wp_password_expired</option>
<option value="_ppm_wp_delayed_reset">_ppm_wp_delayed_reset</option>
<option value="wc_last_active">wc_last_active</option>
<option value="last_update">last_update</option>
<option value="billing_first_name">billing_first_name</option>
<option value="billing_last_name">billing_last_name</option>
<option value="billing_address_1">billing_address_1</option>
<option value="billing_city">billing_city</option>
<option value="billing_state">billing_state</option>
<option value="billing_postcode">billing_postcode</option>
<option value="billing_country">billing_country</option>
<option value="billing_email">billing_email</option>
<option value="billing_phone">billing_phone</option>
<option value="__my_wishlist">__my_wishlist</option>
<option value="billing_company">billing_company</option>
<option value="billing_address_2">billing_address_2</option>
<option value="shipping_first_name">shipping_first_name</option>
<option value="shipping_last_name">shipping_last_name</option>
<option value="shipping_company">shipping_company</option>
<option value="shipping_address_1">shipping_address_1</option>
<option value="shipping_address_2">shipping_address_2</option>
<option value="shipping_city">shipping_city</option>
<option value="shipping_postcode">shipping_postcode</option>
<option value="shipping_country">shipping_country</option>
<option value="shipping_state">shipping_state</option>
</select>
</div>
.bootstrap-select.open > .dropdown-menu{
/*display: block;*/
opacity: 1;
visibility: visible;
pointer-events: auto;
-webkit-transform: scale(1) translateY(0);
-ms-transform: scale(1) translateY(0);
transform: scale(1) translateY(0);
}
.bootstrap-select > .dropdown-menu{
/*display: none;*/
opacity: 0;
max-height: 330px !important;
visibility: hidden;
overflow: hidden;
-webkit-transform-origin: 50% 0;
-ms-transform-origin: 50% 0;
transform-origin: 50% 0;
-webkit-transform: scale(0.85) translateY(-5px);
-ms-transform: scale(0.85) translateY(-5px);
transform: scale(0.85) translateY(-5px);
-webkit-transition: all 0.2s cubic-bezier(0.5, 0, 0, 1.25), opacity 0.15s ease-out;
transition: all 0.2s cubic-bezier(0.5, 0, 0, 1.25), opacity 0.15s ease-out;
}
body{
background: #D1DCE4;
font-family: 'Roboto', sans-serif;
}
.box{
width: 400px;
height: 120px;
position: absolute;
margin: auto;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
h2{
text-align: center;
}
.bootstrap-select:not([class*=col-]):not([class*=form-control]):not(.input-group-btn){
width: 100%;
}
.bootstrap-select>.dropdown-toggle{
background: #EDF2F5;
border: 0;
width: 100%;
display: block;
padding: 16px 15px;
color: #000000;
font-size: 14px;
font-weight: 500;
letter-spacing: 0.030em;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
cursor: pointer;
font-family: 'Roboto', sans-serif;
}
.bootstrap-select>.dropdown-toggle.bs-placeholder, .bootstrap-select>.dropdown-toggle.bs-placeholder:active, .bootstrap-select>.dropdown-toggle.bs-placeholder:focus, .bootstrap-select>.dropdown-toggle.bs-placeholder:hover{
color: #000;
}
.dropdown-toggle::after {
content: "";
position: absolute;
border-top: .5em solid;
border-right: .5em solid transparent;
border-bottom: 0;
border-left: .5em solid transparent;
right: 10px;
top: 48%;
}
.dropdown-menu{
box-shadow: 0px 0px 15px rgba(60, 76, 150, 0.1);
-webkit-box-shadow: 0px 0px 15px rgba(60, 76, 150, 0.1);
-moz-box-shadow: 0px 0px 15px rgba(60, 76, 150, 0.1);
position: absolute;
left: 0;
background: #fff;
min-width: 100% !important;
width: 100% !important;
}
.bootstrap-select .dropdown-menu a{
display: block;
padding: 8px 15px;
font-size: 14px;
font-weight: 500;
letter-spacing: 0.030em;
}
/* ========================================================================
* Bootstrap: dropdown.js v3.4.1
* https://getbootstrap.com/docs/3.4/javascript/#dropdowns
* ========================================================================
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// DROPDOWN CLASS DEFINITION
// =========================
var backdrop = '.dropdown-backdrop'
var toggle = '[data-toggle="dropdown"]'
var Dropdown = function (element) {
$(element).on('click.bs.dropdown', this.toggle)
}
Dropdown.VERSION = '3.4.1'
function getParent($this) {
var selector = $this.attr('data-target')
if (!selector) {
selector = $this.attr('href')
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}
var $parent = selector !== '#' ? $(document).find(selector) : null
return $parent && $parent.length ? $parent : $this.parent()
}
function clearMenus(e) {
if (e && e.which === 3) return
$(backdrop).remove()
$(toggle).each(function () {
var $this = $(this)
var $parent = getParent($this)
var relatedTarget = { relatedTarget: this }
if (!$parent.hasClass('open')) return
if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this.attr('aria-expanded', 'false')
$parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
})
}
Dropdown.prototype.toggle = function (e) {
var $this = $(this)
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
// if mobile we use a backdrop because click events don't delegate
$(document.createElement('div'))
.addClass('dropdown-backdrop')
.insertAfter($(this))
.on('click', clearMenus)
}
var relatedTarget = { relatedTarget: this }
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this
.trigger('focus')
.attr('aria-expanded', 'true')
$parent
.toggleClass('open')
.trigger($.Event('shown.bs.dropdown', relatedTarget))
}
return false
}
Dropdown.prototype.keydown = function (e) {
if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
var $this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
if (!isActive && e.which != 27 || isActive && e.which == 27) {
if (e.which == 27) $parent.find(toggle).trigger('focus')
return $this.trigger('click')
}
var desc = ' li:not(.disabled):visible a'
var $items = $parent.find('.dropdown-menu' + desc)
if (!$items.length) return
var index = $items.index(e.target)
if (e.which == 38 && index > 0) index-- // up
if (e.which == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items.eq(index).trigger('focus')
}
// DROPDOWN PLUGIN DEFINITION
// ==========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.dropdown')
if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
if (typeof option == 'string') data[option].call($this)
})
}
var old = $.fn.dropdown
$.fn.dropdown = Plugin
$.fn.dropdown.Constructor = Dropdown
// DROPDOWN NO CONFLICT
// ====================
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
return this
}
// APPLY TO STANDARD DROPDOWN ELEMENTS
// ===================================
$(document)
.on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
.on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
}(jQuery);
$(function () {
$('.selectpicker').selectpicker();
});