bootstrapSwitch.less 3.1 KB

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