Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="wapper">
  <h2>Custom Select Option</h2>
  <ul class='info'>
    <li>Custom html</li>
    <li>Multiple color</li>
    <li>Typing to search</li>
    <li>Event change</li>
  </ul>
  <div class="style1">
    <select class="select">
      <option value="1">This is a test select option</option>
      <option value="2">Hello World</option>
      <option value="3">Click me!</option>
    </select>
    <select class="select">
      <option value="0">Facebook</option>
      <option value="2">Google</option>
      <option value="3">Yahoo!</option>
      <option value="4" selected="">Twitter</option>
      <option value="5">Princess</option>
      <option value="6">Youtube</option>
      <option value="8">Instagram</option>
    </select>
    <select class="test">
      <option value="0">Firefox</option>
      <option value="2">Chrome</option>
      <option value="3">Safari</option>
      <option value="4">Internet Explorer</option>
    </select>
  </div>
  <div id="event-change"></div>
</div>
<a href="https://codepen.io/HieuHuynh/pen/xbqRXe" target="_blank" class="custom-link">Product Animation <i class="fa fa-arrow-right"></i></a>
              
            
!

CSS

              
                
@import url(https://fonts.googleapis.com/css?family=Neucha);
@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css);
/*@import url(font-icomoon.css);*/
@import url(https://code.ionicframework.com/ionicons/2.0.0/css/ionicons.min.css);
@import url(https://fonts.googleapis.com/css?family=Oswald:400,300,700);
/** Custom field plugin **/
/* SELECT */
.selectCF{
	margin:0;
	padding:0;
	display:inline-block;
	position:relative;
	font-family: 'Neucha', cursive;
	font-size:17px;
	font-weight:bold;
}
.selectCF li{
	list-style:none;
	cursor: pointer;
	perspective: 900px;
	-webkit-perspective: 900px;
  text-align: left;
}
.selectCF > li{
	position:relative;
	font-size:0;
}
.selectCF span{
	display:inline-block;
	height:45px;
	line-height:45px;
	color:#FFF;
	z-index:1;
}
.selectCF .arrowCF{
	transition: .3s;
	-webkit-transition: .3s;
	width:45px;
	text-align:center;
	vertical-align: top;
	font-size:17px;
}
.selectCF .titleCF{
	padding: 0 10px 0 20px;
	border-left: dotted 1px rgba(244,244,244,.5);
	font-size:16px;
	font-family: 'Oswald', sans-serif;
	font-weight:400;
	overflow:hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.selectCF .searchCF{
	padding: 0 10px 0 20px;
	border-left: dotted 1px rgba(244,244,244,.5);
	position: absolute;
	top:0;
	right:0;
	z-index:-1;
}
@keyframes searchActive {
	from{ transform: rotateY(180deg) }
	to{ transform: rotateY(0deg); }
}@-moz-keyframes searchActive {
	from{ transform: rotateY(180deg) }
	to{ transform: rotateY(0deg); }
}
@-webkit-keyframes searchActive {
	from{ -webkit-transform: rotateY(180deg) }
	to{ -webkit-transform: rotateY(0deg); }
}
.searchActive .searchCF{
	z-index:1;
	animation: searchActive 0.3s alternate 1;
	-moz-animation: searchActive 0.3s alternate 1;
	-webkit-animation: searchActive 0.3s alternate 1;
}
.searchActive .titleCF{
	opacity:0;
}
.selectCF .searchCF input{
	font-family: 'Neucha', cursive;
	line-height:45px;
	border:none;
	padding:0;
	margin:0;
	width:100%;
	height:100%;
	background:transparent;
	font-size:17px;
}
.selectCF .searchCF input:active, .selectCF .searchCF input:focus{
	box-shadow:none;
	border:none;
	outline: none;
}
.selectCF li ul{	
	display:none;
	position:absolute;
	top:100%;
	left:0;
	padding: 0 !important;
	width:100%;
	background: #FFF;
	max-height: 255px;
    overflow-y: auto;
	transition: .2s;
	-webkit-transition: .2s;
	z-index:2;
	background:rgba(253,253,253,.9);
  
}
.selectCF li ul li{
	padding:9px 0 9px 20px;
	border-bottom: 1px solid rgba(240,240,240,.9);
	font-weight:normal;
	font-size:14px;
	transition: .2s;
	-webkit-transition: .2s;
	overflow:hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.selectCF li ul li:hover{
	background: #666;
	color:#FFF;
}
.selectCF .selected{
	background: #666;
	color:#FFF;
}
.selectCF li ul li:last-child{
	border-bottom: none;
}
.onCF .arrowCF{
	transform: rotate(90deg);
	-webkit-transform: rotate(90deg);
}
@-moz-keyframes effect1 {
	from{ transform: translateY(15px); opacity:0; }
	to{ transform: translateY(0px); opacity:1; }
}
@-webkit-keyframes effect1 {
	from{ -webkit-transform: translateY(15px); opacity:0; }
	to{ -webkit-transform: translateY(0px); opacity:1; }
}
.onCF li ul{
	display:block;
	-moz-animation: effect1 0.3s alternate 1;
	-webkit-animation: effect1 0.3s alternate 1;
}

/**************************/
html{
  background: url('https://unsplash.com/photos/zJnpPhF4HyY/download');
  background-size: cover;
  text-align: center
}
h2, ul.info li, #event-change{
  font-family: 'Oswald', cursive;
  color: #FFF;
}
ul.info{
  padding: 0;
  margin: 0 0 20px 0;
}
ul.info li{
  display: inline-block;
  border: solid 1px #FFF;
  border-radius: 5px;
  padding: 0 5px;
}
#event-change{
  padding: 20px 0;
}
.custom-link{
  position: absolute;
  bottom: 30px;
  right: 30px;
  color: #FFF;
  font-size: 12px;
  text-decoration: none;
  transition: .3s;
  -webkit-transition: .3s;
  font-family: 'Oswald', sans-serif;
  font-size: 20px
}
a:hover{
  color: #E4432C;
}
              
            
!

JS

              
                (function ( $ ) {
	var elActive = '';
    $.fn.selectCF = function( options ) {
 
        // option
        var settings = $.extend({
            color: "#FFF", // color
            backgroundColor: "#50C9AD", // background
			change: function( ){ }, // event change
        }, options );
 
        return this.each(function(){
			
			var selectParent = $(this);
				list = [],
				html = '';
				
			//parameter CSS
			var width = $(selectParent).width();
			
			$(selectParent).hide();
			if( $(selectParent).children('option').length == 0 ){ return; }
			$(selectParent).children('option').each(function(){
				if( $(this).is(':selected') ){ s = 1; title = $(this).text(); }else{ s = 0; }
				list.push({ 
					value: $(this).attr('value'),
					text: $(this).text(),
					selected: s,
				})
			})
			
			// style
			var style = " background: "+settings.backgroundColor+"; color: "+settings.color+" ";
			
			html += "<ul class='selectCF'>";
			html += 	"<li>";
			html += 		"<span class='arrowCF ion-chevron-right' style='"+style+"'></span>";
			html += 		"<span class='titleCF' style='"+style+"; width:"+width+"px'>"+title+"</span>";
			html += 		"<span class='searchCF' style='"+style+"; width:"+width+"px'><input style='color:"+settings.color+"' /></span>";
			html += 		"<ul>";
			$.each(list, function(k, v){ s = (v.selected == 1)? "selected":"";
			html += 			"<li value="+v.value+" class='"+s+"'>"+v.text+"</li>";})		
			html += 		"</ul>";
			html += 	"</li>";
			html += "</ul>";
			$(selectParent).after(html);
			var customSelect = $(this).next('ul.selectCF'); // add Html
			var seachEl = $(this).next('ul.selectCF').children('li').children('.searchCF');
			var seachElOption = $(this).next('ul.selectCF').children('li').children('ul').children('li');
			var seachElInput = $(this).next('ul.selectCF').children('li').children('.searchCF').children('input');
			
			// handle active select
			$(customSelect).unbind('click').bind('click',function(e){
				e.stopPropagation();
				if($(this).hasClass('onCF')){ 
					elActive = ''; 
					$(this).removeClass('onCF');
					$(this).removeClass('searchActive'); $(seachElInput).val(''); 
					$(seachElOption).show();
				}else{
					if(elActive != ''){ 
						$(elActive).removeClass('onCF'); 
						$(elActive).removeClass('searchActive'); $(seachElInput).val('');
						$(seachElOption).show();
					}
					elActive = $(this);
					$(this).addClass('onCF');
					$(seachEl).children('input').focus();
				}
			})
			
			// handle choose option
			var optionSelect = $(customSelect).children('li').children('ul').children('li');
			$(optionSelect).bind('click', function(e){
				var value = $(this).attr('value');
				if( $(this).hasClass('selected') ){
					//
				}else{
					$(optionSelect).removeClass('selected');
					$(this).addClass('selected');
					$(customSelect).children('li').children('.titleCF').html($(this).html());
					$(selectParent).val(value);
					settings.change.call(selectParent); // call event change
				}
			})
				
			// handle search 
			$(seachEl).children('input').bind('keyup', function(e){
				var value = $(this).val();
				if( value ){
					$(customSelect).addClass('searchActive');
					$(seachElOption).each(function(){
						if( $(this).text().search(new RegExp(value, "i")) < 0 ) {
							// not item
							$(this).fadeOut();
						}else{
							// have item
							$(this).fadeIn();
						}
					})
				}else{
					$(customSelect).removeClass('searchActive');
					$(seachElOption).fadeIn();
				}
			})
			
		});
    };
	$(document).click(function(){
		if(elActive != ''){
			$(elActive).removeClass('onCF');
			$(elActive).removeClass('searchActive');
		}
	})
}( jQuery ));

$(function(){
  var event_change = $('#event-change');
  $( ".select" ).selectCF({
    change: function(){
      var value = $(this).val();
      var text = $(this).children('option:selected').html();
      console.log(value+' : '+text);
      event_change.html(value+' : '+text);
    }
  });
  $( ".test" ).selectCF({
    color: "#FFF",
    backgroundColor: "#663052",
  });
})
              
            
!
999px

Console