js+css实现可拖拽质感数值旋钮调节效果代码

代码语言:html

所属分类:拖放

代码描述:js+css实现可拖拽质感数值旋钮调节效果代码

代码标签: js css 拖拽 质感 数值 旋钮 调节

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

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

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


  
<style>
@import url("https://fonts.googleapis.com/css2?family=Sora:wght@200;400;500&display=swap");
@layer properties {
  @property --value {
    syntax: "<number>";
    inherits: true;
    initial-value: 0;
  }
}
:root {
  --bg-grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 600 600' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  --bg-color: hsl(229deg 29% 10%);
  --glow-color-opacity: 0;
  --glow-color: oklch(82.6% 0.185 76.24 / calc(var(--glow-color-opacity) * 1%));
}

@supports (color: color(display-p3 0 0 0)) {
  :root {
    --glow-color-opacity: 100;
    --glow-color-luminance: 10;
    --glow-color-p3: 0.99 0.71 0.18;
    --glow-color: color-mix(
      in lch,
      color(
        display-p3 var(--glow-color-p3) / calc(var(--glow-color-opacity) * 1%)
      ),
      white calc(var(--glow-color-luminance) * 1%)
    );
  }
}
*,
*:before,
*:after {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background-color: var(--bg-color);
  background-image: radial-gradient(ellipse at 50% 0%, white, rgba(0, 0, 0, 0.4)), repeating-radial-gradient(circle at center, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6) 14px, rgba(255, 255, 255, 0) 18px, rgba(255, 255, 255, 0.3) 18px, rgba(0, 0, 0, 0.6) 21px);
  font-family: "Sora", sans-serif;
  background-blend-mode: soft-light;
  background-size: 100% 100%;
  display: grid;
  place-items: center;
}
body:before {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 50%, transparent 50%, rgba(7, 8, 24, 0.6));
}
body:after {
  position: absolute;
  display: block;
  content: "";
  width: 100%;
  height: 100%;
  background: var(--bg-grain) repeat top left/300px;
  z-index: 10;
  opacity: 0.15;
  mix-blend-mode: color-dodge;
  pointer-events: none;
}

main {
  width: 500px;
  max-width: 100%;
  aspect-ratio: 1/1;
  border-radius: 1000000px;
  background: radial-gradient(ellipse at 50% 0%, #1f1a23, #0a090c);
  position: relative;
  display: block;
  align-items: center;
  justify-content: center;
}
main *, main *:before, main *:after {
  will-change: transform, filter, background;
}
main:after {
  content: "";
  position: absolute;
  width: 80%;
  height: 80%;
  background: #131320;
  display: block;
  border-radius: inherit;
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.8), inset 0 -4px 6px -1px rgba(255, 255, 255, 0.1);
  z-index: inherit;
  margin: auto;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}
main:before {
  content: "";
  display: block;
  position: absolute;
  width: 60%;
  aspect-ratio: 1/1;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), inset 0 -1px 2px rgba(0, 0, 0, 0.3), 0 0 20px 2px rgba(0, 0, 0, 0.2);
  z-index: 11;
  border-radius: 100000px;
  pointer-events: none;
  margin: auto;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}
main .circle-line {
  --glow-color-opacity: calc(var(--value) / 2);
  --glow-color-luminance: 70;
  --glow-color: color-mix(
    in lch,
    color(display-p3 0.99 0.71 0.18 / calc(var(--glow-color-opacity) * 1%)),
    white calc(var(--glow-color-luminance) * 1%)
  );
  position: absolute;
  width: 80.5%;
  height: 80.5%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  background: conic-gradient(from 0.5turn, transparent calc(100% - var(--value) * 1%), var(--glow-color) calc(100% - calc(var(--value) * 1%)));
  -webkit-mask-image: conic-gradient(from 0.5turn, black, black, transparent);
          mask-image: conic-gradient(from 0.5turn, black, black, transparent);
  border-radius: 100000px;
  transform: rotateY(180deg);
}
main .outer-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  transform: rotate(calc(var(--value) * 3.6 * 1deg));
}
main .outer-glow:after {
  content: "";
  display: block;
  position: absolute;
  width: 20px;
  height: 50px;
  background: var(--glow-color);
  border-radius: 100%;
  z-index: 0;
  transform: translate(240px, 500px);
  filter: blur(20px);
  mix-blend-mode: plus-lighter;
  opacity: calc(var(--value) / 100);
}
main > div.inner {
  width: 300px;
  aspect-ratio: 1/1;
  position: absolute;
  margin: auto;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
main > div.inner .halo-outer {
  position: absolute;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 16px black, inset 0 0 8px rgba(0, 0, 0, 0.8), inset 0 0 6px rgba(0, 0, 0, 0.6);
  border-radius: 100000px;
  transform: scale(1.66) rotateY(180deg);
  z-index: 5;
}
main > div.inner .halo-outer:before {
  --glow-color-opacity: calc(var(--value) / 2);
  --glow-color-luminance: 10;
  --glow-color: color-mix(
    in lch,
    color(
      display-p3 var(--glow-color-p3) / calc(var(--glow-color-opacity) * 1%)
    ),
    white calc(var(--glow-color-luminance) * 1%)
  );
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  transform: scale(0.6) rotate(calc(calc(var(--value) * 3.6 * -1deg)));
  border-radius: 100000px;
  background-color: var(--bg-color);
  background-image: radial-gradient(ellipse at 50% calc(210% + calc(var(--value)/2 * -1%)), var(--glow-color) 30%, transparent 40%), linear-gradient(to bottom right, rgba(255, 255, 255, 0.01) 45%, rgba(0, 0, 0, 0) 50%);
  z-index: 2;
  -webkit-backdrop-filter: saturate(1.5);
          backdrop-filter: saturate(1.5);
}
main > div.inner .halo-outer:after {
  content: "";
  display: block;
  position: absolute;
  border-radius: 1000000px;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), rgba(0, 0, 0, 0.1));
  transform: scale(0.6);
  z-index: 6;
  mix-blend-mode: soft-light;
}
main > div.inner .halo-outer canvas {
  position: absolute;
  width: 100% !important;
  height: 100% !important;
  border-radius: 1000000px;
  opacity: 0.05;
  pointer-events: none;
  z-index: -1;
}
main > div.inner .halo-inner {
  --glow-color-opacity: var(--value);
  --glow-color: color-mix(
    in lch,
    color(
      display-p3 var(--glow-color-p3) / calc(var(--glow-color-opacity) * 1%)
    ),
    white 20%
  );
  background: conic-gradient(from 0.5turn, transparent calc(100% - var(--value) * 1%), var(--glow-color) calc(100% - var(--value) * 1%));
  /* With all these transforms, I couldn't figure out a better
   * way to fade out the start of the gradient.   
  */
  -webkit-mask-image: conic-gradient(from 0.5turn, black, black, transparent);
          mask-image: conic-gradient(from 0.5turn, black, black, transparent);
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 100000px;
  opacity: 0.7;
  transform: scale(1.66) rotateY(180deg);
  mix-blend-mode: plus-lighter;
  z-index: -1;
  filter: saturate(2);
  overflow: hidden;
}
main > div.inner .halo-inner:after {
  --current-opacity: opacity(calc(var(--value)*0.01));
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  background: url(//repo.bfw.wiki/bfwrepo/image/6427749a01287.png);
  background-size: 80px;
  -webkit-mask-image: conic-gradient(from 0.5turn, transparent calc(100% - var(--value) * 1%), white calc(100% - var(--value) * 1%));
          mask-image: conic-gradient(from 0.5turn, transparent calc(100% - var(--value) * 1%), white calc(100% - var(--value) * 1%));
  filter: brightness(3400%) url(#turbulence) var(--current-opacity);
  mix-blend-mode: overlay;
}
main > div.inner span {
  display: block;
  position: absolute;
  z-index: 1;
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 1000000px;
  box-shadow: 0 0 26px rgba(0, 0, 0, 0.8);
  transform: rotate(calc(var(--value) * 3.6 * 1deg));
  transform-origin: center center;
}
main > div.inner span:after {
  content: "";
  display: block;
  position: absolute;
  width: 3px;
  height: 99px;
  background: #fff;
  top: 100%;
  left: 50%;
  border-radius: 0 0 2px 2px;
  z-index: -1;
  box-shadow: 0 0 calc(20px + calc(var(--value) / 10 * 1px)) calc(5px + calc(var(--value) / 6 * 1px)) var(--glow-color), inset 0 0 1px var(--glow-color), 0 0 2px 1px black;
  transform: translateX(-50%);
  transform-origin: center top;
  -webkit-animation: reveal 1s ease forwards;
          animation: reveal 1s ease forwards;
  filter: saturate(200%);
}
@-webkit-keyframes reveal {
  from {
    transform: translateX(-50%) scaleY(0);
  }
  to {
    transform: translateX(-50%) scaleY(1);
  }
}
@keyframes reveal {
  from {
    transform: translateX(-50%) scaleY(0);
  }
  to {
    transform: translateX(-50%) scaleY(1);
  }
}
main > div.inner span:before {
  content: "";
  display: block;
  position: absolute;
  width: 3px;
  height: 13%;
  background: #fff;
  top: 105%;
  left: 50%;
  z-index: -1;
  opacity: calc(var(--value) / 5);
  box-shadow: 0 0 calc(20px + calc(var(--value) / 10 * 1px)) calc(5px + calc(var(--value) / 6 * 1px)) var(--glow-color);
  transform: translateX(calc(-50% + 15px));
  filter: blur(5px) saturate(200%) url(#turbulence);
  transform-origin: center left;
}
main > div.inner input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: -webkit-grab;
  cursor: grab;
  z-index: 10;
}
main > div.inner input:active {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}
main > div.inner output {
  color: var(--glow-color);
  position: relative;
  font-variant-numeric: slashed-zero tabular-nums;
  font-feature-settings: "tnum";
  font-size: 5em;
  font-weight: 500;
  position: absolute;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  pointer-events: none;
  position: absolute;
  z-index: 10;
  text-shadow: 0 0 2px black;
}
main > div.inner output:after {
  --glow-color-luminance: 80;
  --glow-color: color-mix(
    in lch,
    color(
      display-p3 0.99 0.71 0.18 / calc(var(--glow-color-opacity) * 1%)
    ),
    white calc(var(--glow-color-luminance) * 1%)
  );
  content: attr(data-value);
  position: absolute;
  top: 0;
  left: 0;
  color: var(--glow-color);
  opacity: 1;
  filter: blur(calc(var(--value)/10*1px)) saturate(5);
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  pointer-events: none;
  mix-blend-mode: plus-lighter;
}

/* Config */
/* Pauls awesome mixin */
.particles-wrapper {
  position: absolute;
  width: 110px;
  height: 110px;
  left: 45%;
  top: 97%;
  overflow: hidden;
  transform: rotate(90deg);
  trasnform-origin: center center;
  -webkit-mask-image: radial-gradient(circle, #000, transparent 70%);
          mask-image: radial-gradient(circle, #000, transparent 70%);
  opacity: calc(var(--value)/10);
  filter: brightness(500%);
}

.particle,
.particle:after {
  background: transparent;
}

.particle:after {
  position: absolute;
  content: "";
  top: 100px;
}

[class*=particle-] {
  border-radius: 10px;
  filter: blur(0.5px) saturate(200%) contrast(200%);
}

.particle-1 {
  -webkit-animation: animParticle calc(20s / calc(var(--value)/10)) linear infinite;
          animation: animParticle calc(20s / calc(var(--value)/10)) linear infinite;
  box-shadow: 0px 0px var(--glow-color), 21px 76px var(--glow-color), 87px 100px var(--glow-color), 134px 104px var(--glow-color), 132px 105px var(--glow-color), 74px 29px var(--glow-color), 48px 118px var(--glow-color), 2px 47px var(--glow-color), 142px 71px var(--glow-color), 83px 34px var(--glow-color), 124px 68px var(--glow-color), 145px 42px var(--glow-color), 134px 94px var(--glow-color), 21px 27px var(--glow-color), 97px 98px var(--glow-color), 87px 121px var(--glow-color), 39px 4px var(--glow-color), 83px 54px var(--glow-color), 58px 21px var(--glow-color), 105px 102px var(--glow-color), 63px 89px var(--glow-color), 91px 36px var(--glow-color), 74px 98px var(--glow-color), 36px 128px var(--glow-color), 30px 103px var(--glow-color), 113px 8px var(--glow-color), 121px 102px var(--glow-color), 132px 1px var(--glow-color), 1px 145px var(--glow-color), 72px 68px var(--glow-color), 21px 87px var(--glow-color), 57px 109px var(--glow-color), 110px 19px var(--glow-color), 54px 59px var(--glow-color), 148px 55px var(--glow-color), 56px 65px var(--glow-color), 17px 70px var(--glow-color), 86px 28px var(--glow-color), 43px 124px var(--glow-color), 117px 45px var(--glow-color), 23px 128px var(--glow-color), 137px 99px var(--glow-color), 64px 101px var(--glow-color), 55px 137px var(--glow-color), 71px 97px var(--glow-color), 17px 103px var(--glow-color), 41px 26px var(--glow-color), 133px 36px var(--glow-color), 71px 116px var(--glow-color), 45px 29px var(--glow-color), 54px 101px var(--glow-color), 85px 33px var(--glow-color), 128px 61px var(--glow-color), 36px 135px var(--glow-color), 139px 41px var(--glow-color), 89px 26px var(--glow-color), 97px 86px var(--glow-color), 83px 120px var(--glow-color), 47px 123px var(--glow-color), 103px 147px var(--glow-color), 7px 128px var(--glow-color), 21px 25px var(--glow-color), 15px 100px var(--glow-color), 138px 60px var(--glow-color), 9px 131px var(--glow-color), 72px 148px var(--glow-color), 62px 66px var(--glow-color), 34px 150px var(--glow-color), 97px 60px var(--glow-color), 30px 136px var(--glow-color), 34px 57px var(--glow-color), 63px 61px var(--glow-color), 91px 109px var(--glow-color), 69px 135px var(--glow-color), 58px 114px var(--glow-color), 23px 145px var(--glow-color), 41px 44px var(--glow-color), 93px 56px var(--glow-color), 116px 37px var(--glow-color), 136px 40px var(--glow-color), 57px 119px var(--glow-color), 70px 147px var(--glow-color), 18px 44px var(--glow-color), 14px 101px var(--glow-color), 51px 135px var(--glow-color), 109px 73px var(--glow-color), 130px 22px var(--glow-color), 35px 120px var(--glow-color), 81px 93px var(--glow-color), 68px 136px var(--glow-color), 64px 27px var(--glow-color), 96px 127px var(--glow-color), 84px 147px var(--glow-color), 40px 130px var(--glow-color), 14px 135px var(--glow-color), 32px 113px var(--glow-color), 5px 95px var(--glow-color), 23px 27px var(--glow-color), 108px 119px var(--glow-color), 72px 4px var(--glow-color), 2px 18px var(--glow-color);
  height: 1px;
  width: 1px;
}

.particle-1:after {
  box-shadow: 0px 0px var(--glow-color), 111px 99px var(--glow-color), 5px 40px var(--glow-color), 22px 22px var(--glow-color), 49px 11px var(--glow-color), 11px 54px var(--glow-color), 19px 46px var(--glow-color), 13px 31px var(--glow-color), 138px 51px var(--glow-color), 60px 87px var(--glow-color), 3px 81px var(--glow-color), 44px 59px var(--glow-color), 51px 147px var(--glow-color), 52px 30px var(--glow-color), 31px 109px var(--glow-color), 147px 120px var(--glow-color), 104px 48px var(--glow-color), 26px 145px var(--glow-color), 148px 147px var(--glow-color), 29px 88px var(--glow-color), 42px 122px var(--glow-color), 105px 25px var(--glow-color), 70px 69px var(--glow-color), 71px 55px var(--glow-color), 118px 7px var(--glow-color), 47px 34px var(--glow-color), 42px 149px var(--glow-color), 149px 143px var(--glow-color), 36px 44px var(--glow-color), 61px 123px var(--glow-color), 20px 7px var(--glow-color), 125px 53px var(--glow-color), 18px 4px var(--glow-color), 77px 27px var(--glow-color), 60px 78px var(--glow-color), 58px 4px var(--glow-color), 103px 93px var(--glow-color), 71px 145px var(--glow-color), 132px 97px var(--glow-color), 94px 121px var(--glow-color), 45px 8px var(--glow-color), 40px 3px var(--glow-color), 34px 114px var(--glow-color), 45px 146px var(--glow-color), 49px 116px var(--glow-color), 103px 42px var(--glow-color), 148px 120px var(--glow-color), 62px 39px var(--glow-color), 131px 140px var(--glow-color), 98p.........完整代码请登录后点击上方下载按钮下载查看

网友评论0