bootstrap-switch.less 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. @import "variables";
  2. @import "mixins";
  3. .has-switch {
  4. display: inline-block;
  5. cursor: pointer;
  6. border-radius: @border-radius-base;
  7. border: 1px solid;
  8. border-color: @btn-default-border;
  9. position: relative;
  10. text-align: left;
  11. overflow: hidden;
  12. line-height: 8px;
  13. .user-select(none);
  14. vertical-align: middle;
  15. min-width: 100px;
  16. .form-control-focus();
  17. .transition(~"border-color ease-in-out .15s, box-shadow ease-in-out .15s");
  18. &.switch-mini {
  19. min-width: 72px;
  20. span,
  21. label {
  22. padding-bottom: 4px;
  23. padding-top: 4px;
  24. font-size: 10px;
  25. line-height: 9px;
  26. }
  27. i.switch-mini-icons {
  28. height: 1.20em;
  29. line-height: 9px;
  30. vertical-align: text-top;
  31. text-align: center;
  32. transform: scale(0.6);
  33. margin-top: -1px;
  34. margin-bottom: -1px;
  35. }
  36. }
  37. &.switch-small {
  38. min-width: 80px;
  39. span,
  40. label {
  41. padding-bottom: 3px;
  42. padding-top: 3px;
  43. font-size: 12px;
  44. line-height: 18px;
  45. }
  46. }
  47. &.switch-large {
  48. min-width: 120px;
  49. span,
  50. label {
  51. padding-bottom: 9px;
  52. padding-top: 9px;
  53. font-size: 16px;
  54. line-height: normal;
  55. }
  56. }
  57. &.switch-animate {
  58. > div {
  59. .transition(left 0.5s);
  60. }
  61. }
  62. &.switch-off {
  63. > div {
  64. left: -50%;
  65. }
  66. }
  67. &.switch-on {
  68. > div {
  69. left: 0%;
  70. }
  71. }
  72. &.disabled {
  73. .opacity(.5);
  74. cursor: default !important;
  75. span,
  76. label {
  77. cursor: default !important;
  78. }
  79. }
  80. > div {
  81. display: inline-block;
  82. width: 150%;
  83. position: relative;
  84. top: 0;
  85. .translate3d(0, 0, 0);
  86. }
  87. input[type=radio],
  88. input[type=checkbox] {
  89. display: none;
  90. }
  91. span,
  92. label {
  93. .box-sizing(border-box);
  94. cursor: pointer;
  95. position: relative;
  96. display: inline-block !important;
  97. height: 100%;
  98. padding-bottom: 4px;
  99. padding-top: 4px;
  100. font-size: 14px;
  101. line-height: 20px;
  102. }
  103. label {
  104. text-align: center;
  105. margin-top: -1px;
  106. margin-bottom: -1px;
  107. z-index: 100;
  108. width: 34%;
  109. background: @btn-default-bg;
  110. i {
  111. color: #000;
  112. text-shadow: 0 1px 0 #fff;
  113. line-height: 18px;
  114. pointer-events: none;
  115. }
  116. }
  117. span {
  118. text-align: center;
  119. z-index: 1;
  120. width: 33%;
  121. &.switch-left {
  122. color: #f00;
  123. .border-left-radius(@border-radius-base);
  124. }
  125. &.switch-right {
  126. color: #000;
  127. background: @gray-lighter;
  128. }
  129. &.switch-primary,
  130. &.switch-left {
  131. color: #fff;
  132. background: @btn-primary-bg;
  133. }
  134. &.switch-info {
  135. color: #fff;
  136. background: @btn-info-bg;
  137. }
  138. &.switch-success {
  139. color: #fff;
  140. background: @btn-success-bg;
  141. }
  142. &.switch-warning {
  143. background: @btn-warning-bg;
  144. color: #fff;
  145. }
  146. &.switch-danger {
  147. color: #fff;
  148. background: @btn-danger-bg;
  149. }
  150. &.switch-default {
  151. color: #000;
  152. background: @gray-lighter;
  153. }
  154. }
  155. }