switch.wxss 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. .switch {
  2. display: inline-block;
  3. width: 100rpx;
  4. height: 60rpx;
  5. border-radius: 64rpx;
  6. border: 2rpx solid #ccc;
  7. background: #00c000;
  8. position: relative;
  9. transition: all 0.35s cubic-bezier(0.45, 1, 0.4, 1);
  10. overflow: hidden;
  11. }
  12. .switch_checked {
  13. border-color: #00c000;
  14. }
  15. .switch view {
  16. position: absolute;
  17. top: 0;
  18. left: 0;
  19. width: 60rpx;
  20. height: 60rpx;
  21. border-radius: 50%;
  22. background: #fff;
  23. box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.4);
  24. transition: all 0.35s cubic-bezier(0.45, 1, 0.4, 1);
  25. }
  26. .switch_checked view {
  27. left: 100%;
  28. transform: translateX(-100%);
  29. }
  30. .switch::before {
  31. display: block;
  32. content: '';
  33. position: absolute;
  34. top: 0;
  35. left: 0;
  36. right: 0;
  37. bottom: 0;
  38. border-radius: 9999rpx;
  39. background: #fff;
  40. transition: all 0.35s cubic-bezier(0.45, 1, 0.4, 1);
  41. }
  42. .switch_checked::before {
  43. transform: scale(0);
  44. }
  45. .switch_disabled::after {
  46. display: block;
  47. content: '';
  48. position: absolute;
  49. top: -2rpx;
  50. left: -2rpx;
  51. right: -2rpx;
  52. bottom: -2rpx;
  53. background: rgba(0, 0, 0, 0.1);
  54. }
  55. .switch_no_radius, .switch_no_radius view, .switch_no_radius::before {
  56. border-radius: 0;
  57. }