bootstrapSwitch.less 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* ============================================================
  2. * bootstrapSwitch v1.3 by Larentis Mattia @spiritualGuru
  3. * http://www.larentis.eu/switch/
  4. *
  5. * bootstrapSwitch v1.3.1 by Stein, Peter @BdMdesigN
  6. *
  7. * enhanced by BdMdesigN
  8. * http://www.bdmdesign.org
  9. * ============================================================
  10. * Licensed under the Apache License, Version 2.0
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. * ============================================================ */
  13. @import "deps/variables";
  14. @import "deps/mixins";
  15. .has-switch {
  16. display: inline-block;
  17. cursor: pointer;
  18. .border-radius(5px);
  19. border: 1px solid;
  20. border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  21. position: relative;
  22. text-align: left;
  23. overflow: hidden;
  24. line-height: 8px;
  25. .user-select(none);
  26. min-width: 100px;
  27. &.switch-mini {
  28. min-width: 72px;
  29. }
  30. &.switch-small {
  31. min-width: 80px;
  32. }
  33. &.switch-large {
  34. min-width: 120px;
  35. }
  36. &.deactivate {
  37. .opacity(50);
  38. cursor: default !important;
  39. label, span {
  40. cursor: default !important;
  41. }
  42. }
  43. > div {
  44. display: inline-block;
  45. width: 150%;
  46. position: relative;
  47. top: 0;
  48. &.switch-animate {
  49. .transition(left 0.5s);
  50. }
  51. &.switch-off {
  52. left: -50%;
  53. }
  54. &.switch-on {
  55. left: 0%;
  56. }
  57. }
  58. input[type=radio],
  59. input[type=checkbox] {
  60. //debug
  61. display: none;
  62. //position: absolute;
  63. //margin-left: 60%;
  64. //z-index: 123;
  65. }
  66. span, label {
  67. .box-sizing(border-box);
  68. cursor: pointer;
  69. position: relative;
  70. display: inline-block;
  71. height: 100%;
  72. padding-bottom: 4px;
  73. padding-top: 4px;
  74. font-size: 14px;
  75. line-height: 20px;
  76. &.switch-mini {
  77. padding-bottom: 4px;
  78. padding-top: 4px;
  79. font-size: 10px;
  80. line-height: 9px;
  81. }
  82. &.switch-small {
  83. padding-bottom: 3px;
  84. padding-top: 3px;
  85. font-size: 12px;
  86. line-height: 18px;
  87. }
  88. &.switch-large {
  89. padding-bottom: 9px;
  90. padding-top: 9px;
  91. font-size: 16px;
  92. line-height: normal;
  93. }
  94. }
  95. label {
  96. text-align: center;
  97. margin-top: -1px;
  98. margin-bottom: -1px;
  99. z-index: 100;
  100. width: 34%;
  101. border-left: 1px solid @btnBorder;
  102. border-right: 1px solid @btnBorder;
  103. .buttonBackground(@btnBackground, @btnBackgroundHighlight);
  104. i {
  105. color: #000;
  106. text-shadow: 0 1px 0 #fff;
  107. line-height: 18px;
  108. pointer-events: none;
  109. }
  110. }
  111. span {
  112. text-align: center;
  113. z-index: 1;
  114. width: 33%;
  115. &.switch-left {
  116. .border-left-radius(4px);
  117. }
  118. &.switch-right {
  119. .buttonBackground(@btnBackgroundHighlight, @btnBackground, @grayDark, 0 1px 1px rgba(255,255,255,.75));
  120. }
  121. &.switch-primary, &.switch-left {
  122. .buttonBackground(@btnPrimaryBackgroundHighlight, @btnPrimaryBackground);
  123. }
  124. &.switch-info {
  125. .buttonBackground(@btnInfoBackgroundHighlight, @btnInfoBackground);
  126. }
  127. &.switch-success {
  128. .buttonBackground(@btnSuccessBackgroundHighlight, @btnSuccessBackground);
  129. }
  130. &.switch-warning {
  131. .buttonBackground(@btnWarningBackgroundHighlight, @btnWarningBackground);
  132. }
  133. &.switch-danger {
  134. .buttonBackground(@btnDangerBackgroundHighlight, @btnDangerBackground);
  135. }
  136. }
  137. }