css实现图案灯打开旋转动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现图案灯打开旋转动画效果代码,点击灯打开或关闭
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> *, *:after, *:before { box-sizing: border-box; transform-style: preserve-3d; } :root { --speed: 5; } body { min-height: 100vh; display: grid; place-items: center; overflow: hidden; background: #1a1a1a; } label { position: fixed; top: 50%; left: 50%; height: 100vh; width: 100vw; transform: translate3d(-50%, -50%, 100vmin); color: transparent; cursor: pointer; } form { margin: 0; } [for="on"] { display: block; } [for="off"] { display: none; } #on:checked ~ .lamp, #on:checked ~ .backdrop { --state: running; --lit: 1; } #on:checked ~ .lamp .lamp__top { background: url(data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEwNyIgaGVpZ2h0PSIxMDMiIHZpZXdCb3g9IjAgMCAxMDcgMTAzIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMjUgMEwzMC42MTI5IDE3LjI3NDZINDguNzc2NEwzNC4wODE4IDI3Ljk1MDhMMzkuNjk0NiA0NS4yMjU0TDI1IDM0LjU0OTFMMTAuMzA1NCA0NS4yMjU0TDE1LjkxODIgMjcuOTUwOEwxLjIyMzU5IDE3LjI3NDZIMTkuMzg3MUwyNSAwWiIgZmlsbD0iI0ZBRjBEMSIvPgo8cGF0aCBkPSJNODQuNDQ2OSA1MS44NTM2TDgzLjExNTkgNjkuOTY4M0w5OS45MzI4IDc2LjgzMTlMODIuMjkzNCA4MS4xNjM5TDgwLjk2MjQgOTkuMjc4Nkw3MS4zOTE2IDgzLjg0MTFMNTMuNzUyMiA4OC4xNzMxTDY1LjQ3NjUgNzQuMzAwM0w1NS45MDU3IDU4Ljg2MjhMNzIuNzIyNiA2NS43MjY0TDg0LjQ0NjkgNTEuODUzNloiIGZpbGw9IiNGQUYwRDEiLz4KPC9zdmc+Cg==) 0 0/20% 20% repeat; } #on:checked ~ [for="off"] { display: block; } #on:checked ~ [for="on"] { display: none; } #off:checked ~ .lamp, #off:checked ~ .backdrop { --state: paused; --lit: 0; } [type="radio"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; } .backdrop { --b-1: hsl(45, 40%, calc((6 + (var(--lit, 0) * 8)) * 1%)); --b-2: hsl(45, 40%, calc((8 + (var(--lit, 0) * 4)) * 1%)); --b-3: hsl(0, 0%, calc((0 + (var(--lit, 0) * 8)) * 1%)); --b-4: hsl(45, 30%, calc((10 + (var(--lit, 0) * 6)) * 1%)); --b-5: hsl(45, 30%, calc((12 + (var(--lit, 0) * 8)) * 1%)); height: 100vh; width: 100vw; background: linear-gradient(var(--b-1) 0, var(--b-2) 61.5%, var(--b-3), var(--b-4) 62.5%, var(--b-5) 100%); position: fixed; top: 50%; left: 50%; z-index: -1; transition: background 0.1s; transform: translate3d(-50%, -50%, -70vmin); } .lamp { --height: 30vmin; height: var(--height); width: calc(var(--height) * 0.875); position: relative; perspective: 800px; --lamp-one: hsla(40, 90%, 98%, var(--lit, 0)); --lamp-two: hsla(40, 50%, 50%, var(--lit, 0)); --lamp-three: hsla(40, 30%, 20%, var(--lit, 0)); --o-1: #1f1f1f; --o-2: #2e2e2e; --o-3: #141414; --l-1: hsla(45, 40%, 82%, calc(0.25 * var(--lit, 0))); --l-2: hsla(45, 40%, 98%, calc(0.25 * var(--lit, 0))); --l-3: hsla(45, 40%, 72%, calc(0.25 * var(--lit, 0))); --lid-1: #121416; --lid-2: #1c1f22; --lid-3: #090a0b; } .lamp__top { position: absolute; top: 8%; left: 50%; transform: translate(-50%, 0); height: 64%; width: 80%; background: url(data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEwNyIgaGVpZ2h0PSIxMDMiIHZpZXdCb3g9IjAgMCAxMDcgMTAzIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMjUgMEwzMC42MTI5IDE3LjI3NDZINDguNzc2NEwzNC4wODE4IDI3Ljk1MDhMMzkuNjk0NiA0NS4yMjU0TDI1IDM0LjU0OTFMMTAuMzA1NCA0NS4yMjU0TDE1LjkxODIgMjcuOTUwOEwxLjIyMzU5IDE3LjI3NDZIMTkuMzg3MUwyNSAwWiIgZmlsbD0iIzUxNTE1MSIvPgo8cGF0aCBkPSJNODQuNDQ2OSA1MS44NTM2TDgzLj.........完整代码请登录后点击上方下载按钮下载查看
网友评论0