cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

              <h1>Advanced Checkbox Hack</h1>

<input type="checkbox" id="button" />
<label for="button" onclick>click / touch</label>

  Change my color!
  <span>even mine :D</span>
              /* Advanced Checkbox Hack */

 * pseudo-class + general/adjacent sibling doesn't work
 * on Android <= 4.1.2 so we need a hack:
 * A useless animation :D
body { -webkit-animation: bugfix infinite 1s; }
@-webkit-keyframes bugfix { from {padding:0;} to {padding:0;} }

input[type=checkbox] {
   position: absolute;
   top: -9999px;
   left: -9999px;

label { 
  cursor: pointer;
  user-select: none;

/* styling */
body {
  font: 1em sans-serif;

h1 {

label {
    margin:0 0 .5em 0;
    padding:1em 2em;

div {
   background: hsla(24, 80%, 50%, .8);
   width: 26em;
   height: 10em;
   line-height: 100px;
   color: white;
   text-align: center;

/* checked */
input[type=checkbox]:checked ~ div {
   background: hsla(120, 80%, 50%, .8);

input[type=checkbox]:checked ~ div span {
  background: hsla(310, 60%, 50%, .8);

input[type=checkbox]:checked ~ label {
   background: hsla(220, 80%, 50%, .8);
  Advanced Checkbox Hack
  # What? #
  The better Checkbox-Hack because it works for both iOS and Android. 

  ## 1. Android <= 4.1.2
  pseudo-class + general/adjacent sibling doesn't 
  work on Android so we need a hack:

  body { -webkit-animation: bugfix infinite 1s; }
  @-webkit-keyframes bugfix { from {padding:0;} to {padding:0;} }

  ## 2. iOS < 6.0
  Due to a bug on iOS it's not possible to click the label
  to toggle the input (checkbox), so we add an empty 
  onclick to the label:

  <label for="button" onclick>click / touch</label>

  # 2012 by Tim Pietrusky
  # timpietrusky.com
🕑 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 ..................