stoyanmkd

Checkbox_example_css

Sep 17th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 2.32 KB | None | 0 0
  1. body  {
  2.   padding: 0  60px;  
  3. }
  4.  
  5. .checkbox, .radio {
  6.   margin-bottom: 20px;
  7. }
  8.  
  9. /* --- START --- */
  10.  
  11. .checkbox *,
  12. .radio *{
  13.   cursor: pointer;
  14. }
  15.  
  16. .checkbox input,
  17. .radio input {
  18.   opacity: 0;
  19. }
  20.  
  21. .checkbox span,
  22. .radio span{
  23.   position: relative;
  24.   display: inline-block;
  25.   margin-left: -25px;
  26.   vertical-align: top;
  27.   width: 30px; height: 30px;
  28.   border-radius: 2px;
  29.   border: 1px solid #ccc;
  30.   border-radius: 20px;
  31. }
  32.  
  33. .checkbox:hover span,
  34. .radio:hover span{
  35.   border-color: teal;
  36. }
  37.  
  38. .checkbox span:before,
  39. .radio span:before{
  40.   position: absolute;
  41.   top: 0; left: 0;  right: 0; bottom: 0;
  42.   opacity: 0;
  43.   text-align: center;
  44.   font-size: 20px;
  45.   line-height: 27px;
  46.   vertical-align: middle;
  47.   color: teal;
  48. }
  49.  
  50. /* override for radio */
  51. .radio span {
  52.   border-radius: 50%;
  53. }
  54. .radio span:before {
  55.   content: "";
  56.   width: 10px; height: 10px;
  57.   margin: 4px auto;
  58.   background-color: teal;
  59.   border-radius: 100px;
  60. }
  61.  
  62. .checkbox input[type=checkbox]:checked + span,
  63. .radio input[type=radio]:checked + span{
  64.   border-color: teal;
  65.   background-color: teal;
  66. }
  67.  
  68. .radio input[type=radio]:checked + span{
  69.   background-color: #fff;
  70. }
  71.  
  72. .checkbox input[type=checkbox]:checked + span:before,
  73. .radio input[type=radio]:checked + span:before{
  74.   color: #fff;
  75.   opacity: 1;
  76.   transition: color .3 ease-out;
  77. }
  78.  
  79. .checkbox input[type=checkbox]:disabled + span,
  80. .radio input[type=radio]:disabled + span{
  81.   border-color: #ddd !important;
  82.   background-color: #ddd !important;
  83. }
  84.  
  85.  
  86. /* --- SWITCH --- */
  87.  
  88. .switch * {
  89.   cursor: pointer;
  90. }
  91.  
  92. .switch input {
  93.   opacity: 0;
  94.   position: absolute;
  95.   z-index: -1;
  96. }
  97. .switch span {
  98.   position: relative;
  99.   display: inline-block;
  100.   width: 58px; height: 30px;
  101.   background-color: #fff;
  102.   border: 1px solid #ddd;
  103.   border-radius: 100px;
  104.   transition: all .5s;
  105.   box-shadow: 1px 2px 3px rgba(0,0,0,0.1) inset;
  106. }
  107.  
  108. .switch span:after {
  109.  content: "";
  110.  position: absolute;
  111.  background-color: #fff;
  112.  top: 0; left: 0;
  113.  height: 28px; width: 28px;
  114.  border: 1px solid #ddd;
  115.  border-radius: 400px;
  116.  box-shadow: 1px 1px 3px rgba(0,0,0,0.1);
  117.  -webkit-transition: all .2s;
  118. }
  119.  
  120. .switch input:checked + span {
  121.   background-color: teal;
  122.   border-color: teal;
  123.   transition: all .5s;
  124. }
  125.  
  126. .switch input:checked + span:after {
  127.   left: 50%;
  128.   transition: all .2s;
  129. }
Advertisement
Add Comment
Please, Sign In to add comment