publish: false

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Document</title>
  8. </head>
  9. <style>
  10. label {
  11. display: block;
  12. vertical-align: middle;
  13. }
  14. label,
  15. input,
  16. select {
  17. vertical-align: middle;
  18. }
  19. .mui-switch {
  20. width: 52px;
  21. height: 31px;
  22. position: relative;
  23. border: 1px solid #dfdfdf;
  24. background-color: #fdfdfd;
  25. box-shadow: #dfdfdf 0 0 0 0 inset;
  26. border-radius: 20px;
  27. border-top-left-radius: 20px;
  28. border-top-right-radius: 20px;
  29. border-bottom-left-radius: 20px;
  30. border-bottom-right-radius: 20px;
  31. background-clip: content-box;
  32. display: inline-block;
  33. -webkit-appearance: none;
  34. user-select: none;
  35. outline: none;
  36. }
  37. .mui-switch:before {
  38. content: '';
  39. width: 29px;
  40. height: 29px;
  41. position: absolute;
  42. top: 0px;
  43. left: 0;
  44. border-radius: 20px;
  45. border-top-left-radius: 20px;
  46. border-top-right-radius: 20px;
  47. border-bottom-left-radius: 20px;
  48. border-bottom-right-radius: 20px;
  49. background-color: #fff;
  50. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  51. }
  52. .mui-switch:checked {
  53. border-color: #64bd63;
  54. box-shadow: #64bd63 0 0 0 16px inset;
  55. background-color: #64bd63;
  56. }
  57. .mui-switch:checked:before {
  58. left: 21px;
  59. }
  60. .mui-switch.mui-switch-animbg {
  61. transition: background-color ease 0.4s;
  62. }
  63. .mui-switch.mui-switch-animbg:before {
  64. transition: left 0.3s;
  65. }
  66. .mui-switch.mui-switch-animbg:checked {
  67. box-shadow: #dfdfdf 0 0 0 0 inset;
  68. background-color: #64bd63;
  69. transition: border-color 0.4s, background-color ease 0.4s;
  70. }
  71. .mui-switch.mui-switch-animbg:checked:before {
  72. transition: left 0.3s;
  73. }
  74. .mui-switch.mui-switch-anim {
  75. transition: border cubic-bezier(0, 0, 0, 1) 0.4s, box-shadow cubic-bezier(0, 0, 0, 1) 0.4s;
  76. }
  77. .mui-switch.mui-switch-anim:before {
  78. transition: left 0.3s;
  79. }
  80. .mui-switch.mui-switch-anim:checked {
  81. box-shadow: #64bd63 0 0 0 16px inset;
  82. background-color: #64bd63;
  83. transition: border ease 0.4s, box-shadow ease 0.4s, background-color ease 1.2s;
  84. }
  85. .mui-switch.mui-switch-anim:checked:before {
  86. transition: left 0.3s;
  87. }
  88. /*# sourceMappingURL=mui-switch.css.map */
  89. </style>
  90. <body>
  91. <label>
  92. <input class="mui-switch" type="checkbox"> 默认未选中</label>
  93. <label>
  94. <input class="mui-switch" type="checkbox" checked> 默认选中</label>
  95. <label>
  96. <input class="mui-switch mui-switch-animbg" type="checkbox"> 默认未选中,简单的背景过渡效果,加mui-switch-animbg类即可</label>
  97. <label>
  98. <input class="mui-switch mui-switch-animbg" type="checkbox" checked> 默认选中</label>
  99. <label>
  100. <input class="mui-switch mui-switch-anim" type="checkbox"> 默认未选中,过渡效果,加 mui-switch-anim 类即可
  101. </label>
  102. <label>
  103. <input class="mui-switch mui-switch-anim" type="checkbox" checked> 默认选中</label>
  104. </body>
  105. </html>