js+svg实现辣椒滑竿滑块取值器效果代码

代码语言:html

所属分类:其他

代码描述:js+svg实现辣椒滑竿滑块取值器效果代码,点击辣椒进行拖拽移动。

代码标签: js svg 辣椒 滑竿 滑块 取值器

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

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

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

  
<style>
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #fff;
  font-size: 3em;
}

.slider-wrapper {
  --slider-height: .3125em;
  --slider-thumb-size: 1.75em;
  --slider-progress: 50;
  border-radius: 50px;
  width: 7em;
  max-width: 100%;
  transition: width 0.2s;
}
.slider-wrapper.unlocked {
  width: 8em;
}

.slider-track {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border-radius: inherit;
  width: 100%;
  height: var(--slider-height);
  background-image: linear-gradient(to right, transparent 0% calc(var(--slider-progress) * 1%), #aaa calc(var(--slider-progress) * 1%) 100%), linear-gradient(to right, #62ad1d, #fbbd1e, #fb6e1e, #e71a1a, #220000);
  background-size: auto, 125% 100%;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.6), inset 0 -2px 4px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: background-size 0.2s;
}
.slider-wrapper.unlocked > .slider-track {
  background-size: auto, 100% 100%;
}

.slider-input {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  z-index: 1;
  left: 50%;
  transform: translate(-50%);
  border-radius: inherit;
  width: calc(100% + var(--slider-thumb-size));
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.slider-input::-webkit-slider-runnable-track {
  height: 100%;
}
.slider-input::-webkit-slider-thumb {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  margin-top: calc((var(--slider-height) / 2) - (var(--slider-thumb-size) / 2));
  border-width: 0;
  border-radius: 50%;
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
}
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0