dzmaktaba

css checkbox

Jan 9th, 2023 (edited)
890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 4.22 KB | Source Code | 0 0
  1. <div class="checkbox-wrapper-1">
  2.   <input id="example-1" class="substituted" type="checkbox" aria-hidden="true" />
  3.   <label for="example-1">Checkbox</label>
  4. </div>
  5.  
  6. <style>
  7.   .checkbox-wrapper-1 *,
  8.   .checkbox-wrapper-1 ::after,
  9.   .checkbox-wrapper-1 ::before {
  10.     box-sizing: border-box;
  11.   }
  12.   .checkbox-wrapper-1 [type=checkbox].substituted {
  13.     margin: 0;
  14.     width: 0;
  15.     height: 0;
  16.     display: inline;
  17.     -webkit-appearance: none;
  18.     -moz-appearance: none;
  19.     appearance: none;
  20.   }
  21.   .checkbox-wrapper-1 [type=checkbox].substituted + label:before {
  22.     content: "";
  23.     display: inline-block;
  24.     vertical-align: top;
  25.     height: 1.15em;
  26.     width: 1.15em;
  27.     margin-right: 0.6em;
  28.     color: rgba(0, 0, 0, 0.275);
  29.     border: solid 0.06em;
  30.     box-shadow: 0 0 0.04em, 0 0.06em 0.16em -0.03em inset, 0 0 0 0.07em transparent inset;
  31.     border-radius: 0.2em;
  32.     background: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xml:space="preserve" fill="white" viewBox="0 0 9 9"><rect x="0" y="4.3" transform="matrix(-0.707 -0.7072 0.7072 -0.707 0.5891 10.4702)" width="4.3" height="1.6" /><rect x="2.2" y="2.9" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 12.1877 2.9833)" width="6.1" height="1.7" /></svg>') no-repeat center, white;
  33.     background-size: 0;
  34.     will-change: color, border, background, background-size, box-shadow;
  35.     transform: translate3d(0, 0, 0);
  36.     transition: color 0.1s, border 0.1s, background 0.15s, box-shadow 0.1s;
  37.   }
  38.   .checkbox-wrapper-1 [type=checkbox].substituted:enabled:active + label:before,
  39.   .checkbox-wrapper-1 [type=checkbox].substituted:enabled + label:active:before {
  40.     box-shadow: 0 0 0.04em, 0 0.06em 0.16em -0.03em transparent inset, 0 0 0 0.07em rgba(0, 0, 0, 0.1) inset;
  41.     background-color: #f0f0f0;
  42.   }
  43.   .checkbox-wrapper-1 [type=checkbox].substituted:checked + label:before {
  44.     background-color: #3B99FC;
  45.     background-size: 0.75em;
  46.     color: rgba(0, 0, 0, 0.075);
  47.   }
  48.   .checkbox-wrapper-1 [type=checkbox].substituted:checked:enabled:active + label:before,
  49.   .checkbox-wrapper-1 [type=checkbox].substituted:checked:enabled + label:active:before {
  50.     background-color: #0a7ffb;
  51.     color: rgba(0, 0, 0, 0.275);
  52.   }
  53.   .checkbox-wrapper-1 [type=checkbox].substituted:focus + label:before {
  54.     box-shadow: 0 0 0.04em, 0 0.06em 0.16em -0.03em transparent inset, 0 0 0 0.07em rgba(0, 0, 0, 0.1) inset, 0 0 0 3.3px rgba(65, 159, 255, 0.55), 0 0 0 5px rgba(65, 159, 255, 0.3);
  55.   }
  56.   .checkbox-wrapper-1 [type=checkbox].substituted:focus:active + label:before,
  57.   .checkbox-wrapper-1 [type=checkbox].substituted:focus + label:active:before {
  58.     box-shadow: 0 0 0.04em, 0 0.06em 0.16em -0.03em transparent inset, 0 0 0 0.07em rgba(0, 0, 0, 0.1) inset, 0 0 0 3.3px rgba(65, 159, 255, 0.55), 0 0 0 5px rgba(65, 159, 255, 0.3);
  59.   }
  60.   .checkbox-wrapper-1 [type=checkbox].substituted:disabled + label:before {
  61.     opacity: 0.5;
  62.   }
  63.  
  64.   .checkbox-wrapper-1 [type=checkbox].substituted.dark + label:before {
  65.     color: rgba(255, 255, 255, 0.275);
  66.     background-color: #222;
  67.     background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xml:space="preserve" fill="rgba(34, 34, 34, 0.999)" viewBox="0 0 9 9"><rect x="0" y="4.3" transform="matrix(-0.707 -0.7072 0.7072 -0.707 0.5891 10.4702)" width="4.3" height="1.6" /><rect x="2.2" y="2.9" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 12.1877 2.9833)" width="6.1" height="1.7" /></svg>');
  68.   }
  69.   .checkbox-wrapper-1 [type=checkbox].substituted.dark:enabled:active + label:before,
  70.   .checkbox-wrapper-1 [type=checkbox].substituted.dark:enabled + label:active:before {
  71.     background-color: #444;
  72.     box-shadow: 0 0 0.04em, 0 0.06em 0.16em -0.03em transparent inset, 0 0 0 0.07em rgba(255, 255, 255, 0.1) inset;
  73.   }
  74.   .checkbox-wrapper-1 [type=checkbox].substituted.dark:checked + label:before {
  75.     background-color: #a97035;
  76.     color: rgba(255, 255, 255, 0.075);
  77.   }
  78.   .checkbox-wrapper-1 [type=checkbox].substituted.dark:checked:enabled:active + label:before,
  79.   .checkbox-wrapper-1 [type=checkbox].substituted.dark:checked:enabled + label:active:before {
  80.     background-color: #c68035;
  81.     color: rgba(0, 0, 0, 0.275);
  82.   }
  83. </style>
  84.  
Advertisement
Add Comment
Please, Sign In to add comment