Simple Select 是一个轻量级的 Select 下拉列表,你可以使用 css 和 jQuery 创建自定义样式的选择元素。

用法

//引入 jQuery 。
<script src="jquery.min.js"></script>
//如果你希望显示一些图标,可以引入 font-awesome 字体图标文件。
<link rel="stylesheet" type="text/css" href="font-awesome.min.css" />
HTML
<div class="select">
<span class="placeholder">Select your language</span>
<ul>
<li data-value="es">España- Español</li>
<li data-value="en">United States - English</li>
<li data-value="fr">France - Français</li>
<li data-value="de">Deutschland - Deutsch</li>
</ul>
<input type="hidden" name="changeme"/>
</div>

<br>

<div class="select select--white">
<span class="placeholder">Select your language</span>
<ul>
<li data-value="es">España- Español</li>
<li data-value="en">United States - English</li>
<li data-value="fr">France - Français</li>
<li data-value="de">Deutschland - Deutsch</li>
</ul>
<input type="hidden" name="changemetoo"/>
</div>

CSS

*, *:after, *:before {
  box-sizing: border-box;
}

html {
  box-sizing: inherit;
  background: -webkit-linear-gradient(right, #8e9eab, #eef2f3);
  background: linear-gradient(to left, #8e9eab, #eef2f3);
}

body {
  margin: 10% auto;
  text-align: center;
  font-size: 12px;
}

.select {
  position: relative;
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 325px;
  color: #cccccc;
  vertical-align: middle;
  text-align: left;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  -webkit-touch-callout: none;
}
.select .placeholder {
  position: relative;
  display: block;
  background-color: #393d41;
  z-index: 1;
  padding: 1em;
  border-radius: 2px;
  cursor: pointer;
}
.select .placeholder:hover {
  background: #34383c;
}
.select .placeholder:after {
  position: absolute;
  right: 1em;
  top: 50%;
  -webkit-transform: translateY(-50%);
          transform: translateY(-50%);
  font-family: 'FontAwesome';
  content: '\f078';
  z-index: 10;
}
.select.is-open .placeholder:after {
  content: '\f077';
}
.select.is-open ul {
  display: block;
}
.select.select--white .placeholder {
  background: #fff;
  color: #999;
}
.select.select--white .placeholder:hover {
  background: #fafafa;
}
.select ul {
  display: none;
  position: absolute;
  overflow: hidden;
  overflow-y: auto;
  width: 100%;
  background: #fff;
  border-radius: 2px;
  top: 100%;
  left: 0;
  list-style: none;
  margin: 5px 0 0 0;
  padding: 0;
  z-index: 100;
  max-height: 120px;
}
.select ul li {
  display: block;
  text-align: left;
  padding: 0.8em 1em 0.8em 1em;
  color: #999;
  cursor: pointer;
}
.select ul li:hover {
  background: #4ebbf0;
  color: #fff;
}

JS

$('.select').on('click','.placeholder',function(){
  var parent = $(this).closest('.select');
  if ( ! parent.hasClass('is-open')){
    parent.addClass('is-open');
    $('.select.is-open').not(parent).removeClass('is-open');
  }else{
    parent.removeClass('is-open');
  }
}).on('click','ul>li',function(){
  var parent = $(this).closest('.select');
  parent.removeClass('is-open').find('.placeholder').text( $(this).text() );
  parent.find('input[type=hidden]').attr('value', $(this).attr('data-value') );
});