switch.scss 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. .m-switch-default{
  2. display: inline-flex;
  3. align-items: center;
  4. .m-switch-content{
  5. display: inline-flex;
  6. align-items: center;
  7. position: relative;
  8. font-size: 14px;
  9. width: 45px;
  10. height: 22px;
  11. line-height: 22px;
  12. vertical-align: middle;
  13. input{
  14. position: absolute;
  15. width: 0;
  16. height: 0;
  17. opacity: 0;
  18. margin: 0;
  19. }
  20. .core{
  21. display: inline-block;
  22. width: 100%;
  23. height: 100%;
  24. border: 1px solid #dcdfe6;
  25. outline: none;
  26. border-radius: 10px;
  27. box-sizing: border-box;
  28. background: #dcdfe6;
  29. cursor: pointer;
  30. transition: all .3s;
  31. vertical-align: middle;
  32. &::after{
  33. content: '';
  34. position: absolute;
  35. top: 2px;
  36. left: 1px;
  37. border-radius: 100%;
  38. background-color: #fff;
  39. width: 18px;
  40. height: 18px;
  41. transition: all .3s;
  42. }
  43. .m-switch-inner{
  44. color: #fff;
  45. position: absolute;
  46. top: 2px;
  47. left: 1px;
  48. width: 18px;
  49. height: 18px;
  50. display: flex;
  51. justify-content: center;
  52. align-items: center;
  53. left: 50%;
  54. white-space: nowrap;
  55. transition: all .3s;
  56. }
  57. }
  58. .off{
  59. background-color: #C0CCDA;
  60. }
  61. .on{
  62. background-color: #409eff;
  63. &::after{
  64. left: 100%;
  65. margin-left: -19px;
  66. }
  67. .m-switch-inner{
  68. left: 50%;
  69. margin-left: -19px;
  70. }
  71. }
  72. }
  73. // 禁止
  74. .is-disabled{
  75. color: #fff;
  76. cursor: no-drop;
  77. opacity: .6;
  78. .core{
  79. cursor: no-drop;
  80. }
  81. }
  82. .m-switch-label{
  83. height: 22px;
  84. line-height: 22px;
  85. display: inline-block;
  86. font-size: 14px;
  87. font-weight: 500;
  88. cursor: pointer;
  89. vertical-align: middle;
  90. color: #303133;
  91. transition:all .2s;
  92. }
  93. .m-switch-label-left{
  94. margin-right: 10px;
  95. }
  96. .m-switch-label-right{
  97. margin-left: 10px;
  98. }
  99. .is-active{
  100. color: #409eff;
  101. }
  102. }
  103. // size为large
  104. .m-switch--large{
  105. font-size: 16px;
  106. line-height: 24px;
  107. .m-switch-label{
  108. height: 24px;
  109. font-size: 16px;
  110. }
  111. .m-switch-content{
  112. width: 55px;
  113. height: 24px;
  114. border-radius: 12px;
  115. .core{
  116. width: 100%;
  117. height: 100%;
  118. border-radius: 12px;
  119. &::after{
  120. width: 20px;
  121. height: 20px;
  122. }
  123. }
  124. .on{
  125. &::after{
  126. left: 100%;
  127. margin-left: -21px;
  128. }
  129. .m-switch-inner{
  130. left: 50%;
  131. margin-left: -21px;
  132. }
  133. }
  134. }
  135. }
  136. .m-switch--small{
  137. font-size: 12px;
  138. line-height: 16px;
  139. height: 24px;
  140. .m-switch-label{
  141. height: 20px;
  142. font-size: 12px;
  143. }
  144. .m-switch-content{
  145. width: 40px;
  146. height: 20px;
  147. border-radius: 8px;
  148. .core{
  149. width: 100%;
  150. height: 100%;
  151. &::after{
  152. width: 16px;
  153. height: 16px;
  154. }
  155. }
  156. .on{
  157. &::after{
  158. left: 100%;
  159. margin-left: -18px;
  160. }
  161. .m-switch-inner{
  162. width: 16px;
  163. height: 16px;
  164. left: 50%;
  165. margin-left: -18px;
  166. }
  167. }
  168. }
  169. }