RangeSlider.vue 1.64 KB
Newer Older
hucy's avatar
hucy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
<script setup lang="ts">
import { ref } from 'vue';
const rangeValue = ref(25);
function onChange(e: any) {
  rangeValue.value = e.target.value;
}
</script>
<template>
  <div class="content fit center">
    <div class="box">
      <input
        type="range"
        class="range"
        value="25"
        min="0"
        max="100"
        @mousemove="onChange"
        @change="onChange"
      />
      <span id="rangeValue">{{ rangeValue }}</span>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.content {
  background: #edf1f4;
}
.box {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.05), #edf1f4);
  border-radius: 40px;
  box-shadow: 15px 15px 20px rgba(0, 0, 0, 0.1), -15px -15px 20px #fff;
}
.range {
  width: 360px;
  height: 15px;
  appearance: none;
  background: #edf1f4;
  outline: none;
  border-radius: 15px;
  box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.1), -5px -5px 10px #fff;
  inset: 5px 5px 5px rgba(0, 0, 0, 0.1);
  overflow: hidden;

  &::-webkit-slider-thumb {
    appearance: none;
    width: 15px;
    height: 15px;
    background: #fff;
    border-radius: 50%;
    border: 2px solid #f7b32d;
    box-shadow: -367px 0 0 360px #f7b32d;
    cursor: pointer;
  }
}
#rangeValue {
  position: relative;
  text-align: center;
  width: 50px;
  font-size: 1.25em;
  font-weight: 500;
  color: #fff;
  background: #f8bc46;
  margin-left: 15px;
  border-radius: 25px;

  box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1), -5px -5px 10px #fff,
    inset 5px 5px 10px rgba(0, 0, 0, 0.1),
    inset -5px -5px 5px rgba(255, 255, 255, 0.25);
}
</style>