css实现垂直滑块拖动炫酷数字动画效果代码
代码语言:html
所属分类:其他
代码描述:css实现垂直滑块拖动炫酷数字动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body, div, datalist, output, section { display: grid; } html { height: 100%; } body { overflow-x: hidden; /* because range input takes up space horizontally before rotation */ background: #1f1f1f; } @supports (line-height: tan(45deg)) { body { --trig: none ; } } @supports (color: color-mix(in lch, red 1%, tan)) { body { --cmix: none ; } } .wrap { --rng: calc(var(--max) - var(--min)); /* range between max and min values */ --prg: calc((var(--val) - var(--min))/var(--rng)); /* decimal progress */ --prc: calc(var(--prg)*100%); /* percentage progress */ --pos: calc(var(--val)*1rem); /* position from 1st ruler line (from val = min) */ grid-gap: 1.25rem; /* space out ruler, track, thumb, output value */ grid-template-columns: -webkit-max-content 0.1875rem 1.25rem -webkit-max-content; grid-template-columns: max-content 0.1875rem 1.25rem max-content; place-self: center; color: #f43e75; /*fallback */ font: 1em trebuchet ms, ubuntu, verdana, arial, sans-serif; transition: 0.35s; /* focus/ hover transition */ } @supports (color: color-mix(in lch, red 1%, tan)) { .wrap { color: color-mix(in lch, #f43e75 var(--prc), #daff47); } } .wrap:not(:focus-within):not(:hover) { filter: sepia(1); } .wrap::before, .wrap::after { /* making up visual track */ --pos-x: calc(100% + 1.875rem); /* x position of middle rounding circle centre */ --pos-y: calc(var(--pos) + 7.4375rem); /* y position considering vertical overflow */ --sl: transparent calc(100% + -.5px), red calc(100% + .5px); /* mask gradient stop list */ grid-area: 1/1/span 1/span 2; /* cover first two columns */ place-self: center end; /* attach to middle right of rightmost cell they cover */ z-index: 1; /* both on top of ruler */ width: 5.5625rem; /* make it wide enough to contain the glow */ height: calc(100% + 2*7.4375rem); /* long enough to contain the glow at min/ max */ transform: scaley(-1); /* ugh... maybe I could have flipped the gradients instead */ content: ""; } .wrap::before { background: radial-gradient(circle 7.4375rem at var(--pos-x) var(--pos-y), currentcolor 4.0625rem, transparent); -webkit-mask: radial-gradient(circle 4.25rem at var(--pos-x) var(--pos-y), var(--sl)), radial-gradient(circle 4.4375rem at 0 0, var(--sl)) 100% calc(var(--pos-y) + -1*5.9686681932rem)/4.4375rem 2.9199240082rem no-repeat, radial-gradient(circle 4.4375rem at 0 100%, var(--sl)) 100% calc(var(--pos-y) + 3.048744185rem)/4.4375rem 2.9199240082rem no-repeat; -webkit-mask-composite: source-out, source-over; mask: radial-gradient(circle 4.25rem at var(--pos-x) var(--pos-y), var(--sl)) subtract, radial-gradient(circle 4.4375rem at 0 0, var(--sl)) 100% calc(var(--pos-y) + -1*5.9686681932rem)/4.4375rem 2.9199240082rem no-repeat add, radial-gradient(circle 4.4375rem at 0 100%, var(--sl)) 100% calc(var(--pos-y) + 3.048744185rem)/4.4375rem 2.9199240082rem no-repeat; } .wrap::after { --sl: transparent calc(4.25rem + -.5px), red calc(4.25rem + .5px) calc(100% + -.5px), transparent calc(100% + .5px); background: linear-gradient(currentcolor calc(var(--pos-y) + 6rem), transparent calc(var(--pos-y) + 2*6rem)) #666; -webkit-mask: linear-gradient(red calc(var(--pos-y) + -1*5.9686681932rem + .5px), transparent 0 calc(var(--pos-y) + 5.9686681932rem + -.5px), red 0) 100%/0.1875rem 100%, radial-gradient(circle 4.4375rem at var(--pos-x), var(--sl)) 100% calc(var(--pos-y) + -1*3.048744185rem + -.5px)/100% calc(2*3.048744185rem + 1px), radial-gradient(circle 4.4375rem at 0 0, var(--sl)) 100% calc(var(--pos-y) + -1*5.9686681932rem)/4.4375rem 2.9199240082rem, radial-gradient(circle 4.4375rem at 0 100%, var(--sl)) 100% calc(var(--pos-y) + 3.048744185rem)/4.4375rem 2.9199240082rem; mask: linear-gradient(red calc(var(--pos-y) + -1*5.9686681932rem + .5px), transparent 0 calc(var(--pos-y) + 5.9686681932rem + -.5px), red 0) 100%/0.1875rem 100%, radial-gradient(circle 4.4375rem at var(--pos-x), var(--sl)) 100% calc(var(--pos-y) + -1*3.048744185rem + -.5px)/100% calc(2*3.048744185rem + 1px), radial-gradient(circle 4.4375rem at 0 0, var(--sl)) 100% calc(var(--pos-y) + -1*5.9686681932rem)/4.4375rem 2.9199240082rem, radial-gradient(circle 4.4375rem at 0 100%, var(--sl)) 100% calc(var(--pos-y) + 3.048744185rem)/4.4375rem 2.9199240082rem; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; } [type=range] { --sel: 0; place-self: center; width: calc(var(--max)*1rem + 6rem); height: 1.25rem; transform: rotate(-90deg); background: transparent; font: inherit; cursor: pointer; } [type=range], [type=range]::-webkit-slider-runnable-track, [type=range]::-webkit-slider-thumb { -webkit-appearance: none; } [type=range]:focus { outline: none; } [type=range]:hover, [type=range]:focus { --sel: 1 ; } [type=range]::-webkit-slider-runnable-track { height: 100%; } [type=range]::-moz-range-track { height: 100%; } [type=range]::-webkit-slider-thumb { margin-top: -2.375rem; --shl: 0 0 0 calc((1 - .375*var(--sel))*1rem) /* slightly decrease spread in hover/ focus case */ hsla(0, 0%, 19%, var(--sel)) /* non-zero shadow alpha only in hover/ focus case */; box-sizing: border-box; border: none; /* get rid of Firefox border */ padding: 0.625rem; /* to add space around bg limited to content-box */ width: 6rem; height: 6rem; /* aspect-ratio: 1 doesn't work here in Firefox */ border-radius: 50%; box-shadow: 0 0 0.5px black, inset 0 0 1px 1px rgba(255, 255, 255, 0.05), inset var(--shl), inset 0 0 0 calc(.5*0.42*(6rem + -2*0.625rem) + 0.625rem) #1f1f1f, 0.25rem -0.25rem 0.25rem #2a2a2a, -0.25rem 0.25rem 0.75rem #090909, var(--shl), 0.75rem -0.75rem 0.75rem #2a2a2a, -0.75rem 0.75rem 1.25rem #090909; background: repeating-conic-gradient(from 60deg, transparent 0%, silver 1deg 59deg, transparent 60deg 50%) 0/42% 100% space content-box #1f1f1f; -webkit-transition: box-shadow 0.35s; transition: box-shadow 0.35s; cursor: ns-resize; } [type=range]::-moz-range-thumb { --shl: 0 0 0 calc((1 - .375*var(--sel))*1rem) /* slightly decrease spread in hover/ focus case */ hsla(0, 0%, 19%, var(--sel)) /* non-zero shadow alpha only in hover/ focus case */; box-sizing: border-box; border: none; /* get rid of Firefox border */ padding: 0.625rem; /* to add space around bg limited to content-box */ width: 6rem; height: 6rem; /* aspect-ratio: 1 doesn't work here in Firefox */ border-radius: 50%; box-shadow: 0 0 0.5px black, inset 0 0 1px 1px rgba(255, 255, 255, 0.05), inset var(--shl), inset 0 0 0 calc(.5*0.42*(6rem + -2*0.625rem) + 0.625rem) #1f1f1f, 0.25rem -0.25rem 0.25rem #2a2a2a, -0.25rem 0.25rem 0.75rem #090909, var(--shl), 0.75rem -0.75rem 0.75rem #2a2a2a, -0.7.........完整代码请登录后点击上方下载按钮下载查看
网友评论0