switch.css 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. .toggle {
  2. position: relative;
  3. display: block;
  4. margin: 0 auto;
  5. width: 7.5rem;
  6. height: 2.8rem;
  7. color: white;
  8. outline: 0;
  9. text-decoration: none;
  10. border-radius: 8rem;
  11. border: 2px solid #546e7a;
  12. background-color: #263238;
  13. -webkit-transition: all 500ms;
  14. -moz-transition: all 500ms;
  15. -o-transition: all 500ms;
  16. transition: all 500ms;
  17. }
  18. .toggle:active {
  19. background-color: #1c2429;
  20. }
  21. .toggle:hover:not(.toggle--moving):after {
  22. background-color: #455a64;
  23. }
  24. .toggle:after {
  25. display: block;
  26. position: absolute;
  27. top: 3px;
  28. bottom: 3px;
  29. /* left: 4px; */
  30. width: calc(50% - 4px);
  31. line-height: 2.12rem;
  32. height: 2.12rem;
  33. text-align: center;
  34. text-transform: uppercase;
  35. font-size: 20px;
  36. color: white;
  37. background-color: #37474f;
  38. border: 2px solid;
  39. -webkit-transition: all 500ms;
  40. -moz-transition: all 500ms;
  41. -o-transition: all 500ms;
  42. transition: all 500ms;
  43. }
  44. .toggle--on:after {
  45. content: "On";
  46. border-radius: 50px 5px 5px 50px;
  47. color: #66bb6a;
  48. left: 4px;
  49. }
  50. .toggle--off:after {
  51. content: "Off";
  52. border-radius: 5px 50px 50px 5px;
  53. color: #f44336;
  54. left: -4px;
  55. -webkit-transform: translate(100%, 0);
  56. -moz-transform: translate(100%, 0);
  57. -o-transform: translate(100%, 0);
  58. transform: translate(100%, 0);
  59. }
  60. .toggle--moving {
  61. background-color: #1c2429;
  62. }
  63. .toggle--moving:after {
  64. color: transparent;
  65. border-color: #435862;
  66. background-color: #222c31;
  67. -webkit-transition: color 0s, transform 500ms, border-radius 500ms,
  68. background-color 500ms;
  69. -moz-transition: color 0s, transform 500ms, border-radius 500ms,
  70. background-color 500ms;
  71. -o-transition: color 0s, transform 500ms, border-radius 500ms,
  72. background-color 500ms;
  73. transition: color 0s, transform 500ms, border-radius 500ms,
  74. background-color 500ms;
  75. }
  76. @media (max-width: 1366px) {
  77. .toggle:after {
  78. top: 3px;
  79. top: 3px;
  80. }
  81. }
  82. @media (min-width: 1920px) {
  83. .toggle:after {
  84. top: 5px;
  85. top: 5px;
  86. }
  87. }