div+css实现弹性checkbox立体质感开关效果代码
代码语言:html
所属分类:布局界面
代码描述:div+css实现弹性checkbox立体质感开关效果代码
代码标签: div css 弹性 checkbox 立体 质感 开关
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background: #1f1f23; margin: 0; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 5em; gap: 0.5em; } @property --color { syntax: '<color>'; inherits: true; initial-value: red; } @property --light-on { syntax: '<color>'; inherits: true; initial-value: #0001; } @property --light-off { syntax: '<color>'; inherits: true; initial-value: #000d; } @keyframes squeeze { 0%, 100% { width: 0.95em; aspect-ratio: 1; } 50% { width: 1.35em; aspect-ratio: 1.75; } } @keyframes squeeze2 { 0%, 100% { width: 0.95em; aspect-ratio: 1; } 50% { width: 1.35em; aspect-ratio: 1.75; } } .ellastic { --on: #af5; --off: #d55; --duration: 0.75s; --color: var(--off); --color-semi: color-mix(in srgb, var(--color) 50%, #0000); --color-semi2: color-mix(in srgb, var(--color) 33%, #0000); --color-semi3: color-mix(in srgb, var(--color) 15%, #fff0); --light-on: #0001; --light-off: #000d; appearance: none; font-size: 1em; width: 2.5em; aspect-ratio: 2.5; border-radius: 3em; border: 1px solid #0000; position: relative; color: var(--color); filter: drop-shadow(0 0.025em 0.0125em #fff3) drop-shadow(0 -0.025em 0.0125em #000c) ; transition: --color var(--duration) linear, --light-on calc(var(--duration) / 2), --light-off calc(var(--duration) / 2), color var(--duration) linear; atransition-delay: 0s, calc(var(--duration) / 1), 0s, 0s; &::after { content: ""; position: absolute; top: 50%; left: 0.5em; transform: translate(-50%, -50%); width: 0.95em; aspect-ratio: 1; border-radius: 5em; border: 1px solid #0000; background: radial-gradient(at 50% 0, var(--color-semi), #0000 40%), ra.........完整代码请登录后点击上方下载按钮下载查看
网友评论0