bootstrapSwitch.less 3.2 KB

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