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.

            
              <div style="padding: 1em">

  <div class="c-cb">
    <input type="checkbox" name="c_input" id="c_input_1">
    <label for="c_input_1">
      Option 1
    </label>
    <!-- 
      this span is for the checkbox animation alone.

      if a checkbox needs to be checked by default, the 
      current CSS will automatically animate the checkmark.
      Some JavaScript could be written to add/remove on
      checking/unchecking the input instead, to mitigate
      this possibility of extra animation.
    -->
    <span class="c-cb__animated"></span>
  </div>
  
  <div class="c-cb">
    <input type="checkbox" id="c_input_2" disabled>
    <label for="c_input_2">
      Option 2
    </label>
    <span class="c-cb__animated"></span>
  </div>

</div>
            
          
!
            
              /**
  Custom styles
*/
.c-cb {
	padding-left: 2em;
	position: relative;
}

.c-cb > input[type="checkbox"] {
	-moz-appearance: none;
	-webkit-appearance: none;
	appearance: none;
	margin-left: -2em;
	margin-top: .75em;
	opacity: .00001;
	position: relative;
	vertical-align: top;
	z-index: 2;
}

/**
 * Make sure the label is only as wide as the
 * inner text requires it to be.
 * The label should not be a block element
 * or run 100% width of its container.
 * Why would someone expect to click
 * white space on the opposite side of the
 * screen to have a checkbox checked?
 */
.c-cb > label {
	display: inline-block;
	padding: .75em .5em;
	vertical-align: top;
}


/**
 * Note, the :before pseudo-element is the new
 * "bounds" or "box" of the checkbox.
 * It must be the same height, width and
 * position of the native checkbox element.
 */
.c-cb > label:before,
.c-cb > input[type="checkbox"] {
	height: 1.125em;
	left: .125em;
	width: 1.125em;
}

/**
 * Base styles for use on both
 * pseudo elements.
 */
.c-cb > label:before,
.c-cb > label:after,
.c-cb__animated {
	border: 1px solid;
	content: " ";
	position: absolute;
	transition:
		border-color .2s ease-in-out,
		box-shadow .2s ease-in-out,
		transform .2s ease-in-out;
}

/**
 * Styles for the custom box boundary.
 */
.c-cb > label:before {
	border-color: #565656;
	border-radius: 2px;
	box-shadow: 0 0 0 1px #565656;
	height: 1.125em;
	left: .125em;
	top: .825em;
	width: 1.125em;
}

/**
 * This recreates the "check" mark.
 */
.c-cb > label:after,
.c-cb__animated {
	border: 0;
	border-bottom: 4px solid #565656;
	border-right: 4px solid #565656;
	height: .825em;
	left: .425em;
	top: .825em;
	transform-origin: center center;
	transform: rotate(45deg) scale(0);
	width: .5em;
}

.c-cb__animated {
  visibility: hidden;
}


/**
 * ** Defining States **
 */
.c-cb > input:checked ~ label:before {
	border-color: transparent;
	box-shadow: 0 0 0 2px #0d5192;
}

.c-cb > input:focus ~ label:before {
	border-color: transparent;
	box-shadow: 0 0 0 3px #228BEC;
}

.c-cb > input:checked ~ label:after,
.c-cb > input:checked ~ .c-cb__animated {
	transform: rotate(45deg) scale(1);
}

.c-cb > input:checked:focus ~ label:after,
.c-cb > input:checked ~ .c-cb__animated {
	border-color: #228BEC;
}

.c-cb > input[disabled] + label:before, // ie11
.c-cb > input[disabled] + label {
	opacity: .625;
}


.c-cb > input:checked ~ .c-cb__animated {
  animation: expand .8s;
}

@keyframes expand {
  0% {
    transform: rotate(45deg) scale(0);
    opacity: 1;
    visibility: visible;
  }
  50% {
    transform: rotate(45deg) scale(2.5);
    opacity: 1;
  }
  100% {
    opacity: 0;
    top: 0px;
    transform: rotate(45deg) scale(2.5);
    visibility: hidden;
  }
}



/**
  some normalization and base styling to slightly pretty up the demo
*/

input,
button,
textarea,
select {
	border-radius: 0; /* may change, but start consistently */
	box-sizing: border-box;
	font-family: inherit;
	font-size: inherit;
	font-weight: inherit;
	line-height: normal;
	margin: 0;
	overflow: visible; /* show overflow in Edge */
	text-transform: none; /* remove inheritance Edge, Firefox, IE */
}

html,
body {
	background: #fcfcfc;
	font-family: arial;
	font-size: 100%;
	margin: 0;
	padding: 0;
}

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

body {
	line-height: 1.4;
}
            
          
!
            
              /**

Notes:
* The native input is visually hidden, but not as a 1px by 1px block.  It is positioned and set to an almost zero opacity on top of the custom style so that it can be discovered by certain types of screen reader navigation methods.
* The checkbox UI is recreated using :before and :after pseudo elements of the sibling <label> element.
* The checkbox's :checked, :focus and :disabled states will serve as hooks to modify the pseudo elements of the label by use of sibling selectors.
* Wrapping the input within a parent container means that it can be appropriately positioned on top of the faux checkbox UI, and the wrapper being set to position relative will keep it in place.

For full documentation about this pattern
and how the particular decisions made here
promote better UX for screen readers, 
please review:
https://scottaohara.github.io/a11y_styled_form_controls/src/checkbox/

For more information on other styled native form controls,
please review:
https://scottaohara.github.io/a11y_styled_form_controls/

*/
            
          
!
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