css美化checkbox开关实现日夜切换代码
代码语言:html
所属分类:表单美化
代码描述:css美化checkbox开关实现日夜切换代码单悬停动画效果代码
代码标签: css 美化 checkbox 开关 实现 日夜 切换 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: grid; place-items: center; margin: 0; min-height: 100vh; font-size: 15vmin; /* background: #004; */ transition: background 0.4s; } body:has(:checked) { /* background: #ffa94c; */ } @property --x { syntax: '<percentage>'; inherits: true; initial-value: 35%; } @property --c1 { syntax: '<color>'; inherits: true; initial-value: #00002e; } @property --c2 { syntax: '<color>'; inherits: true; initial-value: #593d92; } @property --c3 { syntax: '<color>'; inherits: true; initial-value: #ddf; } @property --c4 { syntax: '<color>'; inherits: true; initial-value: #593d92; } @property --x1 { syntax: '<length>'; inherits: true; initial-value: 0px; } @property --x2 { syntax: '<length>'; inherits: true; initial-value: 0px; } @property --x3 { syntax: '<length>'; inherits: true; initial-value: 0px; } @property --x4 { syntax: '<length>'; inherits: true; initial-value: 0px; } @keyframes moveStar1 { 0% { --x1: 0em; } 100% { --x1: 2em; } } @keyframes moveStar2 { 0% { --x2: 0em; } 100% { --x2: 2em; } } @keyframes moveStar3 { 0% { --x3: 0em; } 100% { --x3: 2em; } } @keyframes moveStar4 { 0% { --x4: 0em; } 100% { --x4: 2em; } } .dark-2 { --c1: #00002e; --c2: #593d92; --c3: #ddfd; --c4: #593d9255; --x: 35%; --x1: 1.5em; --x2: 1.5em; --x3: 1.5em; --x4: 1.5em; appearance: none; position: relative; font-size: 1em; height: 1em; width: auto; aspect-ratio: 2; -webkit-aspect-ratio:2; box-sizing: content-box; border: 1px solid #0000; border-radius: 1em; background-image: linear-gradient(var(--c1), #0000 85%); background-clip: border-box; background-color: #1a0e99; overflow: hidden; transition: background-color 0.3s, --x 0.3s, --c1 0.3s, --c2 0.3s, --c3 0.2s, --c4 0.2s; &::before { content: ""; inset: 0; position: absolute; background: conic-gradient(at 96% calc(100% - 0.1em), #0000 150deg, #dde 0 210deg, #0000 0) var(--x1) 0.5em / 100% 100%, conic-gradient(at 96% 0.1em, #dde 30deg, #0000 0 330deg, #dde 0) var(--x1) 0.43em / 100% 100%, conic-gradient(at 96% calc(100% - 0.06em), #0000 150deg, #dde 0 210deg, #0000 0) var(--x2) 0.25em / 100% 100%, conic-gradient(at 96% 0.06em, #dde 30deg, #0000 0 330deg, #dde 0) var(--x2) 0.21em / 100% 100%, conic-gradient(at 96% calc(100% - 0.06em), #0000 150deg, #dde 0 210deg, #0000 0) var(--x3) 0.85em / 100% 100%, conic-gradient(at 96% 0.06em, #dde 30deg, #0000 0 330deg, #dde 0) var(--x3) 0.81em / 100% 100%, conic-gradient(at 96% calc(100% - 0.075em), #0000 150deg, #dde 0 210deg, #0000 0) var(--x4) 0.65em / 100% 100%, conic-gradient(at 96% 0.075em, #dde 30deg, #0000 0 330deg, #dde 0) var(--x4) 0.6em / 100% 100% ; animation: moveStar1 4.75s -3s linear infinite, moveStar2 5.5s -1.75s linear infinite, moveStar3 5s -4.17s linear infinite, moveStar4 5.25s -2.5s linear infinite; filter: drop-shadow(0 0 0.05em #fff); pointer-events: none; } &::after { content: ".........完整代码请登录后点击上方下载按钮下载查看
网友评论0