bootstrap-switch.less 4.6 KB

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