css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              
  <h2>Little test for some nice replacement Checkboxes / Radios. All CSS/jQuery by myself.</h2>

<div class="wrapper">
  
  <label for="chk">checkbox</label>
  <input type="checkbox" id="chk" name="chk"> <input type="checkbox" id="chk2" name="chk2" checked>
  
  <br><br>
  
  <label for="rad">radio</label>
  <input type="radio" id="rad" name="rad[]">
  <input type="radio" id="rad2" name="rad[]">
  <input type="radio" id="rad3" name="rad[]" checked>
 
  <input type="radio" id="rad7" name="rad[1]">
  <input type="radio" id="rad8" name="rad[1]" checked>
  
  
</div>
            
          
!
            
              
    
    /* why not try uncommenting 
    /* one of these lovely colors? */
    @highlight: #05abe0;
    //@highlight: #7a8999;
    //@highlight: #e93cec;
    //@highlight: #55dd00;
    
    /* if you are experiencing the
    /* radios and the button being
    /* slightly misaligned (and moving
    /* by 1px(ish)) then resize your browser.
    /* Codepen's frames seem to be the 
    /* culprit */

		
		label.chkbox {
		  
			display: inline-block; *display: inline; *zoom:1; position: relative; z-index: 2;
			vertical-align: top; 
		  
			width: 48px; height: 16px; border-radius: 5px;
			margin: 0 5px 5px 0; padding: 7px 10px;
			
			cursor: pointer; overflow: hidden;
			
			background-color: #cfcfcf; color: white;
			box-shadow: 0 1px 15px rgba(0,0,0,0.1) inset, 0 1px 4px rgba(0,0,0,0.1) inset, 1px -1px 2px rgba(0,0,0,0.1);
		  
		  	-webkit-transition: background-color .4s ease;
		  	-moz-transition: background-color .4s ease;
		  	-ms-transition: background-color .4s ease;
		  	-o-transition: background-color .4s ease;
		  	transition: background-color .4s ease;
		  
		  
				.yes, .no { 
					position: absolute; 
					right: 8px; text-indent: -999em;
					height: 20px; width: 20px;
					background-repeat: no-repeat;
				}
				.no { 
					margin-top: -2px;
					background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3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TFFMjgxM0ZCNTVDNUM0QjlEREIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDoxQzVENjQzQjZEOEYxMUUyODEzRkI1NUM1QzRCOUREQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDoxQzVENjQzQzZEOEYxMUUyODEzRkI1NUM1QzRCOUREQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PrTLJacAAAGWSURBVHjaYvz//z8DCDAyMjKQAECKmYAYpPkfzAwQYGEgHTADMTcQcwHxTyD+AsS/YZJMJBrGCDVMds6cOeH+/v5qQDY7igqQc5GdTABwALHyuXPnVgD1/H/16tVOIJ8HZgbYHBIMBPlGDOiy/P9Q8PHjxy1AMVZyDAR5lQeIdb58+fIcZNifP38+Hj16VAckh89AkCvYoBg5fEF8OaABs2Cue/nyZRNMDS4D4QEOxApAzA/VAMLCOTk5ATDDvn//fhk5MnAZCA6jDRs2VG/fvr0PyNYCYl6oVzWeP39+Dmbg7du3/aEOwGsg46pVq4xhmo4cOTIbKAZKFkq7du3qgYkDY3YKevrFGYZr166V/Pv37weY5pqamkwLCwu/X79+fYZFxPLly6XQYwxfpDDeu3fPD2bg58+fXwC9dwzGv3//fiK2zEAo2TC9fv268T8a+Pr162FobDOQaiAIsALT2yaYYchpjlwDGfbs2SMONOgBNEfU4cv3ROeUJ0+eCP/48cMNl8uwGchIQsHAQGyGH2EGAgQYANGzvfuxqx8aAAAAAElFTkSuQmCC');
				}
		  
		  
		  
				.toggle {
				
				
					content: " ";
					width: 30px; height: 24px; border-radius: 3px;
					display: block; position: absolute; overflow: hidden; z-index: 3;
					left: 3px; top: 3px;
					
					background: transparent;
					box-shadow: 0 2px 5px 1px rgba(0,0,0,0.2), 0 0 1px rgba(255,255,255,1) inset;
					
					
					transform: translateX(1px);
					-webkit-transition: -webkit-transform 0.3s ease; 
					-moz-transition: -moz-transform 0.3s ease;
					-ms-transition: -ms-transform 0.3s ease;
					-o-transition: -o-transform 0.3s ease;
					transition: transform 0.3s ease;
					
					background-image: linear-gradient( white 0%, #e7e7e7 100% );
					
			
			
					&:after {
					  
						content: " ";
						width: 16px; height: 16px; position: absolute;
						left: 7px; top: 4px; border-radius: 100%; 
						
						background-image: linear-gradient( #ddd 0% , #fff 100% );
						
						box-shadow: 0 0 4px rgba(255,255,255,0.8); 
					  
					}
			
				}
		  
		  &.on {
			
			background-color: @highlight; 
			
			.toggle { 
				transform: translateX(31px); 
			}
			
		  }
		  
		  &.focus {
			  
			outline: 0;
			box-shadow: 0 1px 15px rgba(0,0,0,0.1) inset, 0 1px 4px rgba(0,0,0,0.1) inset, 1px -1px 2px rgba(0,0,0,0.1), 0 0 8px rgba(82,168,236,1), 0 0 1px 1px rgba(0,0,0,.75) inset;  
			  
		  }
		
		}



  



  label.radio {
  
   display: inline-block; height: 24px; width: 24px; position: relative;
  margin: 0 5px 5px 0; padding: 0;
  background-color: #cfcfcf; 
  border-radius: 100%;
  vertical-align: top;
  box-shadow: 0 1px 15px rgba(0,0,0,0.1) inset, 0 1px 4px rgba(0,0,0,0.1) inset, 1px -1px 2px rgba(0,0,0,0.1);
  cursor: pointer; 
  transition: all 0.2s ease;
  
  > span.pip {
    
    width: 16px; height: 16px; position: absolute; border-radius: 100%;
    background: blue;
    top: 4px; left: 4px;
    
    box-shadow: 0 2px 5px 1px rgba(0,0,0,0.3), 0 0 1px rgba(255,255,255,0.4) inset;
    background-image: linear-gradient( white 0, #e7e7e7 100% );
    
    
    transform: scale(0,0);
    transition: all 0.2s ease;
  }
  
  &.on { background-color: @highlight; }
  &.on > span.pip {
    
    transform: scale(1,1);
  }
  
  &.focus {
			  
			outline: 0;
			box-shadow: 0 1px 15px rgba(0,0,0,0.1) inset, 0 1px 4px rgba(0,0,0,0.1) inset, 1px -1px 2px rgba(0,0,0,0.1), 0 0 8px rgba(82,168,236,1), 0 0 1px 1px rgba(0,0,0,.75) inset;   
			  
		  }
  
}





input[type=checkbox].replaced,
input[type=radio].replaced { position: absolute; left: -9999em; }


body { background: radial-gradient(top, ellipse, #fff 0%,#bbddee 100%); padding: 50px 100px; height: 500px; }

.wrapper { width: 270px; margin: 30px auto; }  

label { height: 30px; line-height: 30px; margin-right: 20px; }
h2 { color: #666; text-align: center; width: 560px; margin: 0 auto; line-height: 1.2em }

            
          
!
            
              
    /* jQuery helper funciton to apply 
    /* checkboxes.

    /* there's probably something 
    /* that will not work in some 
    /* occasion so it's simple and 
    /* flexible.

    /* aim to make it completely 
    /* accessible in future */



		$.fn.chkbox = function() {
		  
			return $(this).each( function(k,v) {
			
				var $this = $(v);
				if( $this.is(':checkbox') && !$this.data('checkbox-replaced') ) {
				 	
					// add some data to this checkbox so we can avoid re-replacing it.
					$this.data('checkbox-replaced', true);
          
					// create HTML for the new checkbox.
					var $l = $('<label for="'+$this.attr('id')+'" class="chkbox"></label>');
					var $y = $('<span class="yes">checked</span>');
					var $n = $('<span class="no">unchecked</span>');
					var $t = $('<span class="toggle"></span>');
					
					// insert the HTML in before the checkbox.
					$l.append( $y, $n, $t ).insertBefore( $this );
					$this.addClass('replaced');
					
					// check if the checkbox is checked, apply styling. trigger focus.
					$this.on('change', function() {
					
						if ($this.is(':checked')) {  $l.addClass('on'); }
						else { $l.removeClass('on'); }
						
						$this.trigger('focus');
					
					});
					
					$this.on('focus', function() { $l.addClass('focus') });
					$this.on('blur', function() { $l.removeClass('focus') });
					
					
					
					
					// check if the checkbox is checked on init.
					if ($this.is(':checked')) {  $l.addClass('on'); }
					else { $l.removeClass('on'); }
				  
				}
			
			});
	
		}; 
		$(':checkbox').chkbox();










$.fn.rdo = function() {
		  
			return $(this).each( function(k,v) {
			  
				var $this = $(v);
				if( $this.is(':radio') && !$this.data('radio-replaced') ) {
				 	
					// add some data to this checkbox so we can avoid re-replacing it.
					$this.data('radio-replaced', true);
					
          
					// create HTML for the new checkbox.
					var $l = $('<label for="'+$this.attr('id')+'" class="radio"></label>');
					var $p = $('<span class="pip"></span>');
					
					// insert the HTML in before the checkbox.
					$l.append( $p ).insertBefore( $this );
					$this.addClass('replaced');
					
					// check if the radio is checked, apply styling. trigger focus.
					$this.on('change', function() {
            
            $('label.radio').each( function(k,v) {
              
              var $v = $(v);
              if( $('#'+ $v.attr('for') ).is(':checked') ) {
               $v.addClass('on'); 
              } else {
                $v.removeClass('on'); 
              }
              
            });
            
						$this.trigger('focus');
					
					});
					
					$this.on('focus', function() { $l.addClass('focus') });
					$this.on('blur', function() { $l.removeClass('focus') });
					
					
					
					
					// check if the radio is checked on init.
					$('label.radio').each( function(k,v) {
              
              var $v = $(v);
              if( $('#'+ $v.attr('for') ).is(':checked') ) {
               $v.addClass('on'); 
              } else {
                $v.removeClass('on'); 
              }
              
            });
				  
				}
			
			});
	
		}; 


    $(':radio').rdo();

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console