bootstrap-switch.scss 3.5 KB

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