bootstrap-switch.less 3.9 KB

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