bootstrap-switch.less 3.4 KB

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