index.less 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. @import './var.less';
  2. :root {
  3. --van-slider-active-background-color: @slider-active-background-color;
  4. --van-slider-inactive-background-color: @slider-inactive-background-color;
  5. --van-slider-disabled-opacity: @slider-disabled-opacity;
  6. --van-slider-bar-height: @slider-bar-height;
  7. --van-slider-button-width: @slider-button-width;
  8. --van-slider-button-height: @slider-button-height;
  9. --van-slider-button-border-radius: @slider-button-border-radius;
  10. --van-slider-button-background-color: @slider-button-background-color;
  11. --van-slider-button-box-shadow: @slider-button-box-shadow;
  12. }
  13. .van-slider {
  14. position: relative;
  15. width: 100%;
  16. height: var(--van-slider-bar-height);
  17. background: var(--van-slider-inactive-background-color);
  18. border-radius: var(--van-border-radius-max);
  19. cursor: pointer;
  20. // use pseudo element to expand click area
  21. &::before {
  22. position: absolute;
  23. top: calc(var(--van-padding-xs) * -1);
  24. right: 0;
  25. bottom: calc(var(--van-padding-xs) * -1);
  26. left: 0;
  27. content: '';
  28. }
  29. &__bar {
  30. position: absolute;
  31. width: 100%;
  32. height: 100%;
  33. background: var(--van-slider-active-background-color);
  34. border-radius: inherit;
  35. transition: all var(--van-animation-duration-fast);
  36. }
  37. &__button {
  38. width: var(--van-slider-button-width);
  39. height: var(--van-slider-button-height);
  40. background: var(--van-slider-button-background-color);
  41. border-radius: var(--van-slider-button-border-radius);
  42. box-shadow: var(--van-slider-button-box-shadow);
  43. &-wrapper {
  44. position: absolute;
  45. cursor: grab;
  46. top: 50%;
  47. &--right {
  48. right: 0;
  49. transform: translate3d(50%, -50%, 0);
  50. }
  51. &--left {
  52. left: 0;
  53. transform: translate3d(-50%, -50%, 0);
  54. }
  55. }
  56. }
  57. &--disabled {
  58. cursor: not-allowed;
  59. opacity: var(--van-slider-disabled-opacity);
  60. .van-slider__button-wrapper {
  61. cursor: not-allowed;
  62. }
  63. }
  64. &--vertical {
  65. display: inline-block;
  66. width: var(--van-slider-bar-height);
  67. height: 100%;
  68. .van-slider__button-wrapper--right {
  69. top: auto;
  70. right: 50%;
  71. bottom: 0;
  72. transform: translate3d(50%, 50%, 0);
  73. }
  74. .van-slider__button-wrapper--left {
  75. top: 0;
  76. right: 50%;
  77. left: auto;
  78. transform: translate3d(50%, -50%, 0);
  79. }
  80. // use pseudo element to expand click area
  81. &::before {
  82. top: 0;
  83. right: calc(var(--van-padding-xs) * -1);
  84. bottom: 0;
  85. left: calc(var(--van-padding-xs) * -1);
  86. }
  87. }
  88. }