css实现发光的滑块取值器代码
代码语言:html
所属分类:拖放
代码描述:css实现发光的滑块取值器代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3rem; overflow: hidden; margin: 0; min-height: 100vh; box-sizing: border-box; background-image: linear-gradient(45deg, #223, #112); background: radial-gradient(at 100% 0, #fff2, #fff0 50%), radial-gradient(at 0% 100%, #0002, #0000 50%), #545153; } /* styles based on this guide: - https://www.smashingmagazine.com/2021/12/create-custom-range-input-consistent-browsers/ design based on these demos: - https://codepen.io/alvaromontoro/pen/yLwPvaG - https://codepen.io/jh3y/pen/YzgYPNb */ /* this property may not be needed as we update based on --val */ @property --c { syntax: '<color>'; inherits: true; initial-value: #0000; } .glow { --c: rgb(0, 255, 255, calc(0.25 + var(--val) / 125)); --c: hsl(160deg 80% 50% / calc(0.25 + var(--val) / 125)); -webkit-appearance: none; -moz-appearance: none; appearance: none; background: transparent; cursor: pointer; width: 15rem; position: relative; } .glow::before { content: ""; position: absolute; top: 0; left: 0; width: calc((var(--val) - 1) * 1%); min-width: 0.5em; height: 100%; background: var(--c); box-shadow: 0 0 0.2em 0 hsl(0 0% 0%) inset, -0.1em 0.1em 0.1em -0.1em hsl(0 0% 100% / 0.5), 0 0 calc(1em + 0.001em * var(--val)) calc(0.1em + 0.00025em * var(--val)) var(--c) ; border-radius: 1em 0 0 1em; aopacity: calc(20% + var(--val) * 1%); } /***** Track Styles *****/ /***** Chrome, Safari, Opera, and Edge Chromium *****/ .glow::-webkit-slider-runnable-track { box-shadow: 0 0 0.2em 0 hsl(0 0% 0%) inset, -0.1em 0.1em 0.1em -0.1em hsl(0 0% 100% / 0.5); background: linear-gradient(to bottom right, #0001, #0000), #343133; border-radius: 1em; height: 1em; } /******** Firefox ********/ .glow::-moz-range-track { box-shadow: 0 0 2px 0 hsl(0 0% 0%) inset, -1px 1px 1px -1px hsl(0 0% 100% / 0.5); background: linear-gradient(var(--c) 0 0) 0 0 / calc(var(--val) * 1%) 100% no-repeat, linear-gradient(to bottom right, #0001, #0000), #343133; border-radius: 1em; height: 1em; } /***** Thumb Styles *****/ /***** Chrome, Safari, Opera, and Edge Chromium *****/ .glow::-webkit-slider-thumb { --d: var(--c); --d: rgb(from var(--c) r g b / calc(0.35 * var(--val) * 1%)).........完整代码请登录后点击上方下载按钮下载查看
网友评论0