Advertisement
Guest User

Custom checkbox

a guest
Oct 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.32 KB | None | 0 0
  1. //checkbox
  2.  
  3. input[type=checkbox] {
  4.   position: absolute; // take it out of document flow
  5.   opacity: 0; // hide it
  6.  
  7.   & + label {
  8.     position: relative;
  9.     cursor: pointer;
  10.     padding: 0;
  11.   }
  12.   // Box.
  13.   & + label:before {
  14.     content: '';
  15.     margin-right: 10px;
  16.     display: inline-block;
  17.     vertical-align: text-top;
  18.     width: 18px;
  19.     height: 18px;
  20.     background: transparent;
  21.     border: 1px solid $medium-gray;
  22.     border-radius: 5px;
  23.   }
  24.   // Box hover
  25.   &:hover + label:before {
  26.     background: transparent;
  27.   }
  28.  
  29.   &:checked:hover + label:before {
  30.     background: transparent;
  31.   }
  32.   // Box checked
  33.   &:checked + label:before {
  34.     background: transparent;
  35.   }
  36.   // Disabled state label.
  37.   &:disabled + label {
  38.     color: $dark-gray;
  39.     cursor: auto;
  40.   }
  41.   // Disabled box.
  42.   &:disabled + label:before {
  43.     box-shadow: none;
  44.     background: $dark-gray;
  45.   }
  46.   // Checkmark. Could be replaced with an image
  47.   &:checked + label:after {
  48.     content: '';
  49.     position: absolute;
  50.     left: 4px;
  51.     top: 9px;
  52.     background: $primary-color;
  53.     width: 2px;
  54.     height: 2px;
  55.     box-shadow: 2px 0 0 $primary-color, 4px 0 0 $primary-color, 4px -2px 0 $primary-color, 4px -4px 0 $primary-color, 4px -6px 0 $primary-color, 4px -8px 0 $primary-color;
  56.     transform: rotate(45deg);
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement