Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div class="main">
  
  <h1>Radio Input and Select Element Replacement Demo</h1>
  
  <div class="radioholder">
    <input type="radio" name="projecttype" value="Website" checked>
    <label for="pt_website">Website</label>
  </div>
  <div class="radioholder">
    <input type="radio" name="projecttype" value="Mobile">
    <label for="pt_mobile">Mobile</label>
  </div>
   <div class="radioholder">
    <input type="radio" name="projecttype" value="Application">
    <label for="pt_application">Application</label>
  </div>
  <div class="radioholder">
    <input type="radio" name="projecttype" value="Illustration">
    <label for="pt_illustration">Illustration</label>
  </div>
  
  <div class="selectholder">
    <label>Project Start</label>
    <select name="projectstart" id="projectstart">
      <option value="0">Project Start</option>
      <option value="Immediately">Immediately</option>
      <option value="In the next month">In the next month</option>
      <option value="2 months">2 months</option>
      <option value="3 months">3 months</option>
      <option value="4 months">4 months</option>
      <option value="No rush">No rush</option>
    </select>
  </div>
  <div class="selectholder">
    <label for="projectcompletion">Project Completion</label>
    <select name="projectcompletion" id="projectcompletion">
      <option value="0">Project Completion</option>
      <option value="Immediately">Immediately</option>
      <option value="In the next month">In the next month</option>
      <option value="2 months">2 months</option>
      <option value="3 months">3 months</option>
      <option value="4 months">4 months</option>
      <option value="No rush">No rush</option>
    </select>
  </div>
  
  <p>UI demo of some form element replacements I did for <a href="http://supereightstudio.com/projectplanner">Supereight Studios' new project planner</a>.  There are more container elements than I'd like, and I'm sure the JS could be cleaner but I thought I'd share!</p>

</div>
            
          
!

CSS

            
              @import url(https://fonts.googleapis.com/css?family=Gudea);

body {
  font-family: 'Gudea', Helvetica, sans-serif;
  margin: 0;
  paddong: 0;
  color: #333;
}

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

.main {
  padding: 2em;
  margin: 0 auto;
  width: 100%;
  min-width: 460px;
  max-width: 700px;
}

h1 {
  text-align: center;
  margin: 0 0 1.2em 0;
  line-height: 150%;
}

p {
  margin-top: 2em;
  line-height: 150%;
  text-align: center;
}

a {
  color: #2A817C;
}

a:active,
a:focus,
a:hover {
  color: #E87A31;
}

.radioholder {
	width: 48%;
	background: #fff;
	margin-bottom: 1em;
	font-size: 1.3em;
	height: 2.4em;
	color: #666;
	-o-transition: .1s ease-out;
	-ms-transition: .1s ease-out;
	-moz-transition: .1s ease-out;
	-webkit-transition: .1s ease-out;
	transition: .1s ease-out;
	cursor: pointer;
}


.activeradioholder {
	background: #39A9A4;
	color: #fff;
}

.radioholder .desc {
	display: inline-block;
	vertical-align: middle;
	padding-left: .6em;
	line-height: 2.4em;
}

.radioholder .tick {
	display: inline-block;
	vertical-align: middle;
	width: 2.4em;
	height: 100%;
	background-color: #eee;
	background-image: none;
	-o-transition: .1s ease-out;
	-ms-transition: .1s ease-out;
	-moz-transition: .1s ease-out;
	-webkit-transition: .1s ease-out;
	transition: .1s ease-out;
}

.activeradioholder .tick {
	background-color: #2A817C;
	background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAJFBMVEX////////////////////////////////////////////////Vd7HLAAAAC3RSTlMAESIzRGaZu8zd7m0smEwAAAGRSURBVHja7dtLioQwAADRsW0dP/e/7zCrgl4IgtCWVJ0gLxBCSPJTVVVVVVVVVVVVVVVVVVVVVVVVVVWfzcvwDMe+I3E7kLgdSNwOJG4HErsDidvhlwy/GMySYUGAxO5AYncgsTuQ2B1I5A4kL7eDttHuQGJ3ILE7kNgdSOwOJHYHErkDidtBU44cOXLkyPHf6yGOcburY3iKY5nlDlYuErcDiduBxO1Acq1je3/BgeQ6x/gFBxKzA4ndgUTuoGWwO5DYHUjsDiR2BxKDg5PRkUTgYGSHErsDid2BxO5AYncgsTuQ2B1Ipv1mDjo1w+vtHDTt14fDLcHhluCwS3D4JSsOqYQdxy3B4ZbgcEtwuCU4BBKBA4nWgcTuQGJ3IJE76L3ZHZwY7Q4kdgcSuwOJ3YHE7kBidyCxO5DYHUjsDiR2BxK74/z9j18yCxRIzA4kdgcSuwOJ3YHE70DidyA57xBIcFglOKySVes4ftfsluCQS3DYJTjsEr+DH0tVVVVVVVVVVVVVVVVVVVVVVVXX9Aekh8txA/HicgAAAABJRU5ErkJggg==);
	background-size: cover;
}

.radioholder:nth-child(odd) {
	float: right;
}

.radioholder:nth-child(even) {
	float: left;
}

.radioholder:hover {
	background-color: #eee;
}

.radioholder:hover .tick {
	background-color: #ddd;
}

.activeradioholder:hover {
	background-color: #39A9A4;
}

.activeradioholder:hover .tick {
	background-color: #2A817C;
}

.selectholder {
  clear: both;
	width: 100%;
	background: #eee;
	margin-bottom: 1em;
	font-size: 1.3em;
	height: 2.4em;
	color: #666;
	-o-transition: .1s ease-out;
	-ms-transition: .1s ease-out;
	-moz-transition: .1s ease-out;
	-webkit-transition: .1s ease-out;
	transition: .1s ease-out;
	cursor: pointer;
}

.selectholder .desc {
	display: inline-block;
	vertical-align: middle;
	padding-left: .8em;
	line-height: 2.4em;
}

.selectholder .pulldown {
	float: right;
	vertical-align: middle;
	width: 2.4em;
	height: 100%;
	background-color: #ddd;
	background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAG1BMVEX///9TU1NTU1NTU1NTU1NTU1NTU1NTU1NTU1O/CNq1AAAACHRSTlMAESIzZpnM7hbZ3y0AAAFVSURBVHgB7MGBAAAAAMOg+1MfZNUAAAAAAAAAAAAAAAAAAEg593OMGkEQRDHUvTvdU/c/sRkwdihQYMRWXIL/9lm6XWd3HDNnacfM7ji05HFEJI8DJOAoSP6mgITjjIPHcNxw8BiOGw4ew3HDwWM4bjh4DMcNB4/huOHgMRBnHDwG4oyDx0CcceCYJ65Izowesyj+T8geLSHH7K+WJOoQkqhDSKIOIYk6hCTqEJKoQ0iaDiF5/b6+yg6W3O+fx/fNjrhEOKIS4YhKhKMpuYQjKRl2BCV9B0v6Dr5LO64SgyXs6EvY0Zf0HSzpO1jSd7DEO/oSdvQl7OhL+g6WeEdfwo6+hB19CTv6Eu/oS9jRl7CjL2FHX2IcfQk7+hJ29CXG0Zewoy9hR18iHGkJO/oS4YhKhCMq+RDHd3twLAAAAAAwyN96GHuqEQAAAAAAAAAAAAAAAAHbME5Dn9JRUwAAAABJRU5ErkJggg==);
	background-size: cover;
	-o-transition: .1s ease-out;
	-ms-transition: .1s ease-out;
	-moz-transition: .1s ease-out;
	-webkit-transition: .1s ease-out;
	transition: .1s ease-out;
}

.selectholder:hover,
.activeselectholder {
	background-color: #ddd;
}

.selectholder:hover .pulldown,
.activeselectholder .pulldown {
	background-color: #333;
	background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAG1BMVEX///////////////////////////////////8HBRbfAAAACHRSTlMAESIzZpnM7hbZ3y0AAAFVSURBVHgB7MGBAAAAAMOg+1MfZNUAAAAAAAAAAAAAAAAAAEg593OMGkEQRDHUvTvdU/c/sRkwdihQYMRWXIL/9lm6XWd3HDNnacfM7ji05HFEJI8DJOAoSP6mgITjjIPHcNxw8BiOGw4ew3HDwWM4bjh4DMcNB4/huOHgMRBnHDwG4oyDx0CcceCYJ65Izowesyj+T8geLSHH7K+WJOoQkqhDSKIOIYk6hCTqEJKoQ0iaDiF5/b6+yg6W3O+fx/fNjrhEOKIS4YhKhKMpuYQjKRl2BCV9B0v6Dr5LO64SgyXs6EvY0Zf0HSzpO1jSd7DEO/oSdvQl7OhL+g6WeEdfwo6+hB19CTv6Eu/oS9jRl7CjL2FHX2IcfQk7+hJ29CXG0Zewoy9hR18iHGkJO/oS4YhKhCMq+RDHd3twLAAAAAAwyN96GHuqEQAAAAAAAAAAAAAAAAHbME5Dn9JRUwAAAABJRU5ErkJggg==);
}

.selectholder .selectdropdown {
	position: relative;
	top: 0;
	left: 0;
	background: #333;
	color: #fff;
	display: none;
	clear: both;
}

.selectholder .selectdropdown span {
	display: block;
	border-bottom: solid 1px #555;
	padding-left: .8em;
	line-height: 2.4em;
	width: 100%;
	-o-transition: background-color .1s ease-out;
	-ms-transition: background-color .1s ease-out;
	-moz-transition: background-color .1s ease-out;
	-webkit-transition: background-color .1s ease-out;
	transition: background-color .1s ease-out;
}

.selectholder .selectdropdown span:last-child {
	border-bottom: none;
}

.selectholder .selectdropdown span.active {
	background-color: #2A817C;	
	background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAJFBMVEX////////////////////////////////////////////////Vd7HLAAAAC3RSTlMAESIzRGaZu8zd7m0smEwAAAGRSURBVHja7dtLioQwAADRsW0dP/e/7zCrgl4IgtCWVJ0gLxBCSPJTVVVVVVVVVVVVVVVVVVVVVVVVVVWfzcvwDMe+I3E7kLgdSNwOJG4HErsDidvhlwy/GMySYUGAxO5AYncgsTuQ2B1I5A4kL7eDttHuQGJ3ILE7kNgdSOwOJHYHErkDidtBU44cOXLkyPHf6yGOcburY3iKY5nlDlYuErcDiduBxO1Acq1je3/BgeQ6x/gFBxKzA4ndgUTuoGWwO5DYHUjsDiR2BxKDg5PRkUTgYGSHErsDid2BxO5AYncgsTuQ2B1Ipv1mDjo1w+vtHDTt14fDLcHhluCwS3D4JSsOqYQdxy3B4ZbgcEtwuCU4BBKBA4nWgcTuQGJ3IJE76L3ZHZwY7Q4kdgcSuwOJ3YHE7kBidyCxO5DYHUjsDiR2BxK74/z9j18yCxRIzA4kdgcSuwOJ3YHE70DidyA57xBIcFglOKySVes4ftfsluCQS3DYJTjsEr+DH0tVVVVVVVVVVVVVVVVVVVVVVVXX9Aekh8txA/HicgAAAABJRU5ErkJggg==);
	background-repeat: no-repeat;
	background-size: 1.6em 1.6em;
	background-position: 98% 50%;
}

.selectholder .selectdropdown span:hover {
	background-color: #555;
}

            
          
!

JS

            
              // This really isn't a great way to do this sort of thing any more!
// For some reason this pen is quite popular, but I'd look elsewhere!

$(document).ready(function(){

  // set up radio boxes
	$('.radioholder').each(function(){
		$(this).children().hide();
		var description = $(this).children('label').html();
		$(this).append('<span class="desc">'+description+'</span>');
		$(this).prepend('<span class="tick"></span>');
		// on click, update radio boxes accordingly
		$(this).click(function(){
			$(this).children('input').prop('checked', true);
			$(this).children('input').trigger('change');
		});
	});
	// update radio holder classes when a radio element changes
	$('input[type=radio]').change(function(){
    $('input[type=radio]').each(function(){
      if($(this).prop('checked') == true) {   
        $(this).parent().addClass('activeradioholder');
      }
			else $(this).parent().removeClass('activeradioholder');
		});
	});
	// manually fire radio box change event on page load
	$('input[type=radio]').change();

	// set up select boxes
	$('.selectholder').each(function(){
		$(this).children().hide();
		var description = $(this).children('label').text();
		$(this).append('<span class="desc">'+description+'</span>');
		$(this).append('<span class="pulldown"></span>');
		// set up dropdown element
		$(this).append('<div class="selectdropdown"></div>');
	  $(this).children('select').children('option').each(function(){
			if($(this).attr('value') != '0') {
				$drop = $(this).parent().siblings('.selectdropdown');
				var name = $(this).attr('value');
				$drop.append('<span>'+name+'</span>');
			}
		});
		// on click, show dropdown
		$(this).click(function(){
			if($(this).hasClass('activeselectholder')) {
				// roll up roll up
				$(this).children('.selectdropdown').slideUp(200);
				$(this).removeClass('activeselectholder');
				// change span back to selected option text
				if($(this).children('select').val() != '0') {
					$(this).children('.desc').fadeOut(100, function(){
						$(this).text($(this).siblings("select").val());
						$(this).fadeIn(100);
					});
				}
			}
			else {
				// if there are any other open dropdowns, close 'em
				$('.activeselectholder').each(function(){
					$(this).children('.selectdropdown').slideUp(200);
					// change span back to selected option text
					if($(this).children('select').val() != '0') {
						$(this).children('.desc').fadeOut(100, function(){
							$(this).text($(this).siblings("select").val());
							$(this).fadeIn(100);
						});
					}
					$(this).removeClass('activeselectholder');
				});			
				// roll down
				$(this).children('.selectdropdown').slideDown(200);
				$(this).addClass('activeselectholder');
				// change span to show select box title while open
				if($(this).children('select').val() != '0') {
					$(this).children('.desc').fadeOut(100, function(){
						$(this).text($(this).siblings("select").children("option[value=0]").text());
						$(this).fadeIn(100);
					});
				}
			}
		});
	});
	// select dropdown click action
	$('.selectholder .selectdropdown span').click(function(){
		$(this).siblings().removeClass('active');
		$(this).addClass('active');
		var value = $(this).text();
		$(this).parent().siblings('select').val(value);
		$(this).parent().siblings('.desc').fadeOut(100, function(){
			$(this).text(value);
			$(this).fadeIn(100);
		});
	});

});
            
          
!
999px

Console