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.

            
              <h1>Paper-Checkbox Concept - non Polymer</h1>
<p>Supports IE9+, Chrome (Mobile + Desktop), Safari, Opera, Firefox</p>

<input type="checkbox" id="anId1" class="wskCheckbox" checked="true" />
<label class="wskLabel" for="anId1">Check me out</label>

<input type="checkbox" id="anId2" class="wskCheckbox" />
<label class="wskLabel" for="anId2">I look and feel like Google Material</label>

<input type="checkbox" id="anId3" class="wskCheckbox" />
<label class="wskLabel" for="anId3">But I work even in older browsers</label>

<input type="checkbox" id="anId4" class="wskCheckbox" />
<label class="wskLabel" for="anId4">All you have to do is use regular native HTML elements</label>

<div id="panel">
  <h2>About this</h2>
  <p>This is a small code snippet demonstrating how it is possible to recreate the style and animations of the latest Google Material elements using regular HTML, CSS and JavaScript.</p>
  
  <p>To use this code all you would need to do is write good semantic HTML. In this case yuo need to have a checkbox and a label targeted at the said checkbox using the "for" attribute. You then simply include the example styles and JavaScript on your page and all your checkboxes will be transformed in to the ones you see here. Happy days.</p>
</div>
            
          
!
            
              /* Extra Styles just for this demo. For core checkbox styles see below. */
body {
  font-family: Arial, sans-serif;
}

h1, h2 {
  font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 24pt;
  font-weight: 300;
}

h2 {
  color: #ffffff;
  font-size: 18pt;
  margin: 10px;
}

p {
  color: #4d4d4d;
}

#panel {
  background: #2d3d2d;
  bottom: 0;
  padding: 10px;
  position: fixed;
  right: 0;
  top: 0;
  width: 280px;
}

#panel p {
  color: #dfdfdf;
  margin: 10px;
  font-size:10pt;
}


/* 
 * Core styles required for the checkboxes.
 * @author Jason Mayes 2014, www.jasonmayes.com
*/
.wskLabel {
  cursor: pointer;
  font-size: 12pt;
  display: block;
  overflow: hidden;
  padding-top: 20px;
  position: relative;
  min-height:40px;
}

.wskCheckbox {
  border: 2px solid #5a5a5a;
  color: #1d1d1d;
  cursor: pointer;
  display: inline-block;
  float: left;
  height: 14px;
  margin: 0 20px 20px 20px;
  outline-color: #eaeaea;
  padding: 0;
  position:relative;
  width: 14px;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  z-index:1;
}

.wskCheckbox.checked {
  border-left: 2px solid green;
  border-bottom: 4px solid green;
  border-top: 1px solid rgba(0,0,0,0);
  border-right: 1px solid rgba(0,0,0,0);
  -webkit-transform: rotate(-45deg) scaleY(0.5);
  -moz-transform: rotate(-45deg) scaleY(0.5);
  -ms-transform: rotate(-45deg) scaleY(0.5);
  -o-transform: rotate(-45deg) scaleY(0.5);
  transform: rotate(-45deg) scaleY(0.5);
}

input[type='checkbox'].wskCheckbox {
   display: none;
}

.wskCircle {
  background-color:#ccdffd;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;
  display: block;
  height: 40px;
  left: 9px;
  opacity: 0;
  position: absolute;
  top: 9px;
  -webkit-transition: all 0.15s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
  transition: all 0.15s ease-in-out;
  width: 40px;
  z-index:0;
}

.wskCircle.show {
  opacity: 1;
}

.wskCircle.flipColor {
  background-color: #d2d3d2;
}
            
          
!
            
              /*
 * Material Deesign Checkboxes non Polymer.
 * Tested and working in: IE9+, Chrome (Mobile + Desktop), Safari,
 * Opera, Firefox.
 * @author Jason Mayes 2014, www.jasonmayes.com
*/

var wskCheckbox = function() {
  var wskCheckboxes = [];
  var SPACE_KEY = 32;

  function animateCircle(checkboxElement) {
    var circle =
        checkboxElement.parentNode.getElementsByClassName('wskCircle')[0];
    var restore = '';
    if (circle.className.indexOf('flipColor') < 0) {
      restore = circle.className + ' flipColor';
    } else {
      restore = 'wskCircle';
    }
    circle.className = restore  + ' show';
    setTimeout(function(){
      circle.className = restore;
    }, 150);
  }

  function addEventHandler(elem, eventType, handler) {
    if (elem.addEventListener) {
      elem.addEventListener (eventType, handler, false);
    }
    else if (elem.attachEvent) {
      elem.attachEvent ('on' + eventType, handler);
    }
  }

  function clickHandler(e) {
    e.stopPropagation();
    if (this.className.indexOf('checked') < 0) {
      this.className += ' checked';
    } else {
      this.className = 'wskCheckbox';
    }
    animateCircle(this);
  }

  function keyHandler(e) {
    e.stopPropagation();
    if (e.keyCode === SPACE_KEY) {
      clickHandler.call(this, e);
      // Also update the checkbox state.
      var cbox = document.getElementById(this.parentNode.getAttribute('for'));
      cbox.checked = !cbox.checked;
    }
  }

  function clickHandlerLabel(e) {
    var id = this.getAttribute('for');
    var i = wskCheckboxes.length;
    while (i--) {
      if (wskCheckboxes[i].id === id) {
        if (wskCheckboxes[i].checkbox.className.indexOf('checked') < 0) {
          wskCheckboxes[i].checkbox.className += ' checked';
        } else {
          wskCheckboxes[i].checkbox.className = 'wskCheckbox';
        }
        animateCircle(wskCheckboxes[i].checkbox);
        break;
      }
    }
  }

  function findCheckBoxes() {
    var labels =  document.getElementsByTagName('label');
    var i = labels.length;
    while (i--) {
      var posCheckbox = document.getElementById(labels[i].getAttribute('for'));
      if (posCheckbox !== null && posCheckbox.type === 'checkbox' &&
          (posCheckbox.className.indexOf('wskCheckbox') >= 0)) {
        var text = labels[i].innerText;
        var span = document.createElement('span');
        span.className = 'wskCheckbox';
        span.tabIndex = i;
        var span2 = document.createElement('span');
        span2.className = 'wskCircle flipColor';
        labels[i].insertBefore(span2, labels[i].firstChild);
        labels[i].insertBefore(span, labels[i].firstChild);
        addEventHandler(span, 'click', clickHandler);
        addEventHandler(span, 'keyup', keyHandler);
        addEventHandler(labels[i], 'click', clickHandlerLabel);
        var cbox = document.getElementById(labels[i].getAttribute('for'));
        if (cbox.getAttribute('checked') !== null) {
          span.click();
        }
        
        wskCheckboxes.push({'checkbox': span,
            'id': labels[i].getAttribute('for')});
      }
    }
  }

  return {
    init: findCheckBoxes
  };
}();

wskCheckbox.init();
            
          
!
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