svg+js实现圆弧状时间滑动拖动取值器代码

代码语言:html

所属分类:拖放

代码描述:svg+js实现圆弧状时间滑动拖动取值器代码

代码标签: svg js 圆弧 时间 滑动 拖动 取值器 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  


  
<style>
@import url("https://fonts.googleapis.com/css2?family=Inter&display=swap");
body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  min-height: 100vh;
  background-color: #f2f2f3;
  font-family: "Inter", sans-serif;
  font-size: 2em;
}

.slider-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 12.5em;
  max-width: 100%;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.slider-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.slider-thumb {
  --color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  z-index: 1;
  left: calc(var(--slider-value) / 100 * (100% - var(--slider-height)) + var(--slider-height) / 2);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  width: 1.25em;
  height: 1.25em;
  background-image: linear-gradient(to bottom, #f0f0f2, #d9dade);
  box-shadow: 0 0.0625em 0.0625em rgba(0, 0, 0, 0.3);
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: none;
  cursor: pointer;
}
.slider-thumb::before {
  content: "";
  position: absolute;
  border-radius: inherit;
  width: 68%;
  height: 68%;
  background-color: var(--color);
  box-shadow: inset 0 -8px 4px rgba(0, 0, 0, 0.1);
}

.slider-value-container {
  display: flex;
  justify-content: center;
  align-items: center;
  column-gap: 0.5em;
  position: absolute;
  bottom: 1em;
  transform: translateY(-100%);
  border: 1px solid #dbdbe3;
  border-radius: 50px;
  padding: 0.25em 0.75em;
  background-color: #f2f2f3;
  box-shadow: 0 0.0625em 0.25em rgba(0, 0, 0, 0.1);
  font-size: 0.5em;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.slider-value {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.slider-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 0 #fff);
  overflow: visible;
}

.slider-svg-path {
  touch-action: none;
  cursor: pointer;
}
</style>

  
  
  
</head>

<body >
  <div class="slider-wrapper">
  <input class="slider-input" type="range" value="720" max="1440" step="1">
  <div class="slider-thumb">
    <div class="slider-value-container">
      <p class="slider-value">12:00 PM</p>
    </div>
  </div>
  <svg class="slider-svg" viewBox="0 0 238 36" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path class="slider-svg-path" d="M2 34L7.21879 31.0968C78.5901 -8.60616 165.659 -7.50128 236 34V34" stroke="url(#paint0_linear_339_100980)" stroke-width=".25em" stroke-linecap="round" vector-effect="non-scaling-stroke" filter="url(#filter0_i_339_100980)"/>
    <defs>
      <filter id="filter0_i_339_100980" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
        <feFlood flood-opacity="0" result="BackgroundImageFix"/>
        <feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
        <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
        <feOffset dy="1"/>
        <feGaussianBlur stdDeviation="0.5"/>
        <feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1"/>
        <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
        <feBlend mode="normal" in2="shape" result="effect1_innerShadow_339_100980"/>
      </filter>
      <linearGradient id="paint0_linear_339_100980".........完整代码请登录后点击上方下载按钮下载查看

网友评论0