cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <form action="">
    <fieldset class="options">
        <legend>Radio</legend>
        <ul>
            <li><input id="radio1" name="radio" type="radio" class="radio" checked="checked"> <label for="radio1">Option 1</label></li>
            <li><input id="radio2" name="radio" type="radio" class="radio"> <label for="radio2">Option 2</label></li>
            <li><input id="radio3" name="radio" type="radio" class="radio"> <label for="radio3">Option 3</label></li>
        </ul>
    </fieldset>
    <fieldset class="options">
        <legend>Checkbox</legend>
        <ul>
            <li><input id="checkbox1" name="checkbox" type="checkbox" checked="checked"> <label for="checkbox1">Choice A</label></li>
            <li><input id="checkbox2" name="checkbox" type="checkbox"> <label for="checkbox2">Choice B</label></li>
            <li><input id="checkbox3" name="checkbox" type="checkbox"> <label for="checkbox3">Choice C</label></li>
        </ul>
    </fieldset>
  <!--
  <fieldset>
    <legend>Fields</legend>
    <ul>
      <li>
        <label for="">text</label>
        <input type="text" />
        <span class="error-msg">Error</span>
      </li>
      <li>
        <label for="">email</label>
        <input type="email" required />
        <span class="error-msg">Error</span>
      </li>
      <li>
        <label for="">number</label>
        <input type="number" />
        <span class="error-msg">Error</span>
      </li>
      <li>
        <label for="">password</label>
        <input type="password" placeholder="your password" />
        <span class="error-msg">Error</span>
      </li>
    </ul>
  </fieldset>
-->
  <fieldset>
    <legend>Select</legend>
      <ul>
        <li>
          <select>
            <optgroup label="Option Group 1">
              <option>Option 1</option>
              <option>Option 2</option>
            </optgroup>
            <optgroup>
              <option>Option 3</option>
            </optgroup>
          </select>
      </li>
    </ul>
  </fieldset>
</form>
            
          
!
            
              // mixin
@mixin vh() {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}


body {
  padding: 1em;
}
// custom checkbox/radios
$inputHeight: 14px;
$inputWidth: 14px;
$inputBorderWidth: 2px;
$inputActiveScale: 4px; // optimized for even numbers

input[type="checkbox"],
input[type="radio"] {
  @include vh();

  &:focus,
  &:hover {
    + label {
      &:before {
        border-color: black;
      }
    }
  }

  &:active {
    + label {
      &:before {
      transition-duration: 0;
      filter: brightness(0.2); 
      }
    }
  }

  + label {
    position: relative;
    padding: 10px;
    padding-left: 2em;
    vertical-align: middle;
    user-select: none;

    &:before {
      box-sizing: content-box;
      content: '';
      color: #900;
      position: absolute;
      top: 50%;
      left: 0;
      width: $inputWidth;
      height: $inputHeight;
      margin-top: -($inputHeight/2 + $inputBorderWidth);
      border: $inputBorderWidth solid grey;
      //font-size: 18px;
      text-align: center;
    }
    &:after {
      box-sizing: content-box;
      content: '';
      background-color: #900;
      position: absolute;
      top: 50%;
      left: $inputBorderWidth + $inputActiveScale/2;
      width: $inputWidth - $inputActiveScale;
      height: $inputHeight -$inputActiveScale;
      margin-top: -(($inputHeight - $inputActiveScale)/2);
      transform: scale(0);
      transform-origin: 50%;
      transition: transform 200ms ease-out;
    }
  }
}

input[type="checkbox"]{
  + label {
    &:after {

      background-color: transparent;
      top: 50%;
      left: 4px;
      width: 8px;
      height: 3px;
      margin-top: -4px;
      border-style: solid;
      border-color: #900;
      border-width: 0 0 3px 3px;
      border-image: none;
      transform: rotate(-45deg) scale(0);
      transition: none;
    }
  }
  &:checked {

    + label {
      &:after {
        content: ''; //\2713';

        transform: rotate(-45deg) scale(1);
        transition: transform 200ms ease-out;
      }
    }
  }
}

input[type="radio"] {
  &:checked {
    + label {
      &:before {
        animation: borderscale 300ms ease-in;
        background-color: white;
      }
      &:after {
        transform: scale(1);
      }
    }
  }
  + label {
    &:before,
     &:after {
      border-radius: 50%;
    }
  }
}

input[type="checkbox"]{
  &:checked {
    + label {
      &:before {
        animation: borderscale 200ms ease-in;
      }
      &:after {
        transform: rotate(-45deg) scale(1);
      }
    }
  }
}

@keyframes borderscale {
  50% {
    box-shadow: 0 0 0 2px #900;
  }
}

// select

select {
  appearance: none;
  background-color: #fff;
  background-image: url(data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2216%22%20height%3D%228%22%20viewBox%3D%220%200%2016%208%22%3E%3Cpolygon%20fill%3D%22%234D4D4D%22%20points%3D%228%2C0%2016%2C0%2012%2C4%208%2C8%204%2C4%200%2C0%20%22/%3E%3C/svg%3E);
  background-repeat: no-repeat;
  background-position: 95% 50%;
  border: $inputBorderWidth solid grey;
  border-radius: 0;
  padding: 0.25em 0.4em;
  padding-right: 1.5em;

  &:focus,
  &:hover {
    border-color: black;
    outline: none;
  }

  &:active {
    border-color: #900;
  }

 // Fix Firefox dotted focusring
 &:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 #000;
  }
}

 /* IE 10/11+ - This hides native dropdown button arrow so it will have the custom appearance, IE 9 and earlier get a native select - targeting media query hack via http://browserhacks.com/#hack-28f493d247a12ab654f6c3637f6978d5 - looking for better ways to achieve this targeting */
/* The second rule removes the odd blue bg color behind the text in the select button in IE 10/11 and sets the text color to match the focus style's - fix via http://stackoverflow.com/questions/17553300/change-ie-background-color-on-unopened-focused-select-box */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
	select::-ms-expand {
		display: none;
	}
	select:focus::-ms-value {
		background: transparent;
		color: grey;
	}
}









// errors

.error-msg {
  display: block;
  color: red;
  max-height: 0;
  overflow: hidden;
  
  transition: max-height 500ms ease-out;
  will-change: max-height;
}

// WIP
:required:not(:focus) ~ .error-msg,
:invalid:required ~ .error-msg {
  max-height: 9em;
}

input:focus {
  border: 1px solid black;  
}

input:not(:focus):invalid {
  border: 1px solid red;
  outline: none;
}

input:not(:focus):valid {
  border: 1px solid green;
}





// global
* {
	box-sizing: border-box;
}

form ul {
  list-style: none;
}

label {
	cursor: pointer;
  display: inline-block;
}

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console