css+svg美化checkbox实现点击开灯关灯开关效果代码
代码语言:html
所属分类:其他
代码描述:css+svg美化checkbox实现点击开灯关灯开关效果代码
代码标签: css svg 美化 checkbox 点击 开灯 关灯 开关
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { min-height: 100vh; overflow: hidden; display: flex; justify-content: center; align-items: center; } a.source { position: fixed; top: 1em; } svg { height: 50vh; } .yellow, .yellow .bulb { opacity: 0; } @keyframes flicker { 0% { opacity: 0.4; } 5% { opacity: 0.5; } 10% { opacity: 0.6; } 15% { opacity: 0.85; } 25% { opacity: 0.5; } 30% { opacity: 1; } 35% { opacity: 0.1; } 100% { opacity: 1; } } #cb { display: none; } #cb:checked ~ .light .clear { display: none; } #cb:checked ~ .light .yellow { opacity: 1; } #cb:checked ~ .light .yellow .bulb { animation: flicker 1s; -webkit-animation-fill-mode: forwards; } @media (prefers-reduced-motion) { #cb:checked ~ .light .yellow .bulb { animation: none; opacity: 1; } } </style> </head> <body > <input type="checkbox" id="cb"> <label class="light" for="cb"> <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"> <defs> <style> .hide {display: none;} </style> </defs> <rect class="st0" wid.........完整代码请登录后点击上方下载按钮下载查看
网友评论0