bootstrapSwitch.scss 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* ============================================================
  2. * bootstrapSwitch v1.0 by Larentis Mattia @spiritualGuru
  3. * http://www.larentis.eu/switch/
  4. * ============================================================
  5. * Licensed under the Apache License, Version 2.0
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. * ============================================================ */
  8. @import "compass/css3";
  9. $border: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  10. $white: #ffffff;
  11. $blue: #0088cc;
  12. $gray: #e6e6e6;
  13. $border-radius: 4px;
  14. .switch {
  15. display: inline-block;
  16. cursor: pointer;
  17. @include border-radius(5px);
  18. border: 1px solid;
  19. border-color: $border;
  20. background: $gray;
  21. position: relative;
  22. text-align: left;
  23. overflow: hidden;
  24. line-height: 8px;
  25. // disable text selection highlighting
  26. -webkit-touch-callout: none;
  27. -webkit-user-select: none;
  28. -khtml-user-select: none;
  29. -moz-user-select: none;
  30. -ms-user-select: none;
  31. user-select: none;
  32. min-width: 102px;
  33. &.switch-mini {
  34. min-width: 72px;
  35. }
  36. &.switch-small {
  37. min-width: 81px;
  38. }
  39. &.switch-large {
  40. min-width: 120px;
  41. }
  42. &.deactivate {
  43. @include opacity(0.5);
  44. cursor: default !important;
  45. label, span {
  46. cursor: default !important;
  47. }
  48. }
  49. > div {
  50. display: inline-block;
  51. width: 150%;
  52. position: relative;
  53. top: 0;
  54. &.switch-animate {
  55. @include transition(left 0.5s);
  56. }
  57. &.switch-off {
  58. left: -50%;
  59. }
  60. &.switch-on {
  61. left: 0%;
  62. }
  63. }
  64. input[type=checkbox] {
  65. //debug
  66. display: none;
  67. //position: absolute;
  68. //margin-left: 60%;
  69. //z-index: 123;
  70. }
  71. span, label {
  72. @include box-sizing(border-box);
  73. cursor: pointer;
  74. position: relative;
  75. display: inline-block;
  76. height: 100%;
  77. padding-bottom: 4px;
  78. padding-top: 4px;
  79. font-size: 14px;
  80. line-height: 20px;
  81. &.switch-mini {
  82. padding-bottom: 4px;
  83. padding-top: 4px;
  84. font-size: 10px;
  85. line-height: 9px;
  86. }
  87. &.switch-small {
  88. padding-bottom: 3px;
  89. padding-top: 3px;
  90. font-size: 12px;
  91. line-height: 18px;
  92. }
  93. &.switch-large {
  94. padding-bottom: 9px;
  95. padding-top: 9px;
  96. font-size: 16px;
  97. line-height: normal;
  98. }
  99. }
  100. label {
  101. background: $white;
  102. margin-top: -1px;
  103. margin-bottom: -1px;
  104. z-index: 100;
  105. width: 33.333333%;
  106. border-left: 1px solid $gray;
  107. border-right: 1px solid $gray;
  108. @include background-image(linear-gradient(top, $white, $gray));
  109. }
  110. span {
  111. color: $white;
  112. text-align: center;
  113. z-index: 1;
  114. width: 33.333333%;
  115. &.switch-left {
  116. @include border-top-left-radius($border-radius);
  117. @include border-bottom-left-radius($border-radius);
  118. }
  119. &.switch-right {
  120. color: black;
  121. @include border-top-right-radius($border-radius);
  122. @include border-bottom-right-radius($border-radius);
  123. @include background-image(linear-gradient(bottom, $white, $gray));
  124. }
  125. &.switch-primary, &.switch-left {
  126. color: $white;
  127. background: $blue;
  128. @include background-image(linear-gradient(bottom, $blue, #0055CC));
  129. }
  130. &.switch-info {
  131. $startColor: #5BC0DE;
  132. color: $white;
  133. background: $startColor;
  134. @include background-image(linear-gradient(bottom, $startColor, #2F96B4));
  135. }
  136. &.switch-success {
  137. $startColor: #62C462;
  138. color: $white;
  139. background: $startColor;
  140. @include background-image(linear-gradient(bottom, $startColor, #51A351));
  141. }
  142. &.switch-warning {
  143. $startColor: #DBB450;
  144. color: $white;
  145. background: $startColor;
  146. @include background-image(linear-gradient(bottom, $startColor, #F89406));
  147. }
  148. &.switch-danger {
  149. $startColor: #EE5f5B;
  150. color: $white;
  151. background: $startColor;
  152. @include background-image(linear-gradient(bottom, $startColor, #BD362F));
  153. }
  154. }
  155. }