js+css实现可拖拽质感数值旋钮调节效果代码
代码语言:html
所属分类:拖放
代码描述: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(.........完整代码请登录后点击上方下载按钮下载查看
网友评论0