switches.css 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* ----------------------------------
  2. * CHECKBOXES / RADIOS
  3. * ---------------------------------- */
  4. label.pack-checkbox,
  5. label.pack-radio,
  6. label.pack-switch {
  7. display: inline-block;
  8. vertical-align: middle;
  9. width: 5rem;
  10. height: 5rem;
  11. position: relative;
  12. background: none;
  13. }
  14. label.pack-checkbox input,
  15. label.pack-radio input,
  16. label.pack-switch input {
  17. margin: 0;
  18. opacity: 0;
  19. position: absolute;
  20. top: 0;
  21. left: 0;
  22. }
  23. label.pack-checkbox input ~ span:after,
  24. label.pack-radio input ~ span:after {
  25. content: '';
  26. position: absolute;
  27. left: 50%;
  28. top: 50%;
  29. margin: -1.1rem 0 0 -1.1rem;
  30. width: 2.2rem;
  31. height: 2.2rem;
  32. pointer-events: none;
  33. }
  34. label.pack-checkbox input ~ span:after {
  35. background: url(switches/images/check/default.png) no-repeat center top / 2.2rem auto;
  36. }
  37. label.pack-radio input ~ span:after {
  38. background: url(switches/images/radio/default.png) no-repeat center top / 2.2rem auto;
  39. }
  40. label.pack-checkbox input:checked ~ span:after,
  41. label.pack-radio input:checked ~ span:after,
  42. label.pack-switch input:checked ~ span:after {
  43. background-position: center bottom;
  44. }
  45. /* 'Dangerous' switches */
  46. label.pack-checkbox.danger input ~ span:after {
  47. background-image: url(switches/images/check/danger.png);
  48. }
  49. label.pack-radio.danger input ~ span:after {
  50. background-image: url(switches/images/radio/danger.png);
  51. }
  52. /* ----------------------------------
  53. * ON/OFF SWITCHES
  54. * ---------------------------------- */
  55. label.pack-switch input ~ span:after {
  56. content: '';
  57. position: absolute;
  58. right: 0;
  59. top: 50%;
  60. width: 6rem;
  61. margin: -1.4rem 0 0;
  62. height: 2.7rem;
  63. pointer-events: none;
  64. border-radius: 1.35rem;
  65. overflow: hidden;
  66. background: #e6e6e6 url(switches/images/switch/background_off.png) no-repeat -3.2rem 0 / 9.2rem 2.7rem;
  67. transition: background 0.2s ease;
  68. }
  69. /* switch: 'ON' state */
  70. label.pack-switch input:checked ~ span:after {
  71. background: #e6e6e6 url(switches/images/switch/background.png) no-repeat 0 0 / 9.2rem 2.7rem;
  72. }
  73. /* switch: disabled state */
  74. label.pack-switch input:disabled ~ span:after {
  75. opacity: 0.4;
  76. }
  77. label.pack-switch input.uninit ~ span:after {
  78. transition: none;
  79. }
  80. /******************************************************************************
  81. * Right-To-Left tweaks
  82. */
  83. html[dir="rtl"] label.pack-checkbox input,
  84. html[dir="rtl"] label.pack-radio input,
  85. html[dir="rtl"] label.pack-switch input {
  86. left: auto;
  87. right: 0;
  88. }
  89. html[dir="rtl"] label.pack-checkbox input ~ span:after,
  90. html[dir="rtl"] label.pack-radio input ~ span:after {
  91. left: auto;
  92. right: 50%;
  93. margin-left: auto;
  94. margin-right: -1.1rem;
  95. }
  96. html[dir="rtl"] label.pack-switch input ~ span:after {
  97. left: 0;
  98. right: auto;
  99. }
  100. html[dir="rtl"] label.pack-switch input ~ span:after {
  101. background-position: 0;
  102. }
  103. /* switch: 'ON' state */
  104. html[dir="rtl"] label.pack-switch input:checked ~ span:after {
  105. background-image: url(switches/images/switch/background_rtl.png);
  106. background-position: -3.2rem 0;
  107. }