css+js实现逼真立体数值滑块range拖动取值器效果代码

代码语言:html

所属分类:拖放

代码描述:css+js实现逼真立体数值滑块range拖动取值器效果代码

代码标签: css js 逼真 立体 数值 滑块 range 拖动 取值器

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

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

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

<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500&display=swap" rel="stylesheet">
  
  
  
<style>
* {
  box-sizing: inherit;
  margin: 0;
  font: inherit;
}

.js {
  --js: 1 ;
}

body, form, datalist, option {
  display: grid;
}

body {
  overflow-x: hidden;
  min-height: 100vh;
  background: linear-gradient(to right bottom, #ecf5fa, #d2dbe0);
}
@media (max-width: 320px) {
  body {
    font-size: 0.75em;
  }
}
@media (max-width: 240px) {
  body {
    font-size: 0.625em;
  }
}

form {
  --rng: calc(var(--max) - var(--min));
  --outer-w: clamp(20em, 100vw - 1.5em, 32em);
  --inner-w: calc(var(--outer-w) - 2*0.75em);
  --range-w: calc(var(--inner-w) - 3em);
  --range-u: calc(var(--range-w)/var(--rng));
  --pos: calc(1.5em + (var(--val) - var(--min))*var(--range-u));
  grid-template-rows: 100%;
  place-self: center;
  padding: 1em 0.75em;
  width: var(--inner-w);
  height: 1.75em;
  max-width: 32em;
  border-radius: 1.875em;
  box-shadow: inset -0.25em 0 0.25em #f5f5f5, inset 0.125em 0.25em 0.25em #a0a0a0, inset -0.5em 0 0.5em #ededed, inset 0.25em 0.5em 0.5em #adadad, inset 0.5em 1em 1em #c0c0c0, inset 0 -0.25em 0.25em #d7d7d7;
  background: linear-gradient(#c7c7c7, #ebebeb);
  font: 500 1em/1.25 montserrat, trebuchet ms, arial, sans-serif;
  filter: Saturate(var(--hl, 0));
  transition: filter 0.35s;
}
form::before, form > * {
  grid-area: 1/1;
}
form::before {
  display: var(--js, none);
  place-self: center start;
  width: var(--pos);
  height: 1.5em;
  border-radius: 0.75em;
  box-shadow: 0 0 1px #73a5c5, inset 0 1px 2px #005699, inset 0 -1px 1px #0070bf;
  background: linear-gradient(#0364a1, #0178c0);
  content: "";
}
form:hover, form:focus-within {
  --hl: 1 ;
}

[type=range] {
  align-self: center;
  background: transparent;
  cursor: pointer;
}
[type=range], [type=range]::-webkit-slider-runnable-track, [type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
}
[type=range]::-moz-range-track {
  background: none;
}
[type=range]::-moz-range-progress {
  height: 1.5em;
  border-radius: 0.75em;
  box-shadow: 0 0 1px #73a5c5, inset 0 1px 2px #005699, inset 0 -1px 1px #0070bf;
  background: linear-gradient(#0364a1, #0178c0);
}
[type=range]::-webkit-slider-thumb {
  border: none;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  transform: rotate(45deg);
  background: radial-gradient(closest-side, #f5f5f5, transparent) -10px/65% 85% no-repeat, radial-gradient(closest-side, rgba(245, 245, 245, 0.5), transparent) 65% -5px/50% 50% no-repeat, radial-gr.........完整代码请登录后点击上方下载按钮下载查看

网友评论0