div+scss实现点击发射台发射烟花动画效果代码
代码语言:html
所属分类:动画
代码描述:div+scss实现点击发射台发射烟花动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style type = 'text/scss'> :root { --sp: 2.5s; } @property --load { syntax: '<length>'; inherits: false; initial-value: 26px; } * { box-sizing: border-box; } body { display: flex; justify-content: center; height: 100vh; margin: 0; padding: 0; overflow: hidden; align-items: flex-end; background: linear-gradient(0deg, #081c31 0%, #140214 74%); } body:before { content: ""; position: absolute; width: 100%; height: 100%; left: 0; top: 0; --s1: radial-gradient(0.1vmin 0.1vmin at 50% 50%, #ffffff, #fff0); --s2: radial-gradient(0.2vmin 0.2vmin at 50% 50%, #ffffff, #fff0); background-image: var(--s1),var(--s1), var(--s1),var(--s2), var(--s2),var(--s1), var(--s2),var(--s1), var(--s2),var(--s1), var(--s2),var(--s1), var(--s2),var(--s1), var(--s1),var(--s2), var(--s2),var(--s1), var(--s1),var(--s2), var(--s1),var(--s1); background-repeat: repeat-x; background-position: -8% -10%; background-size: 26% 25%, 43.33% 33.33%, 50% 80%, 20% 20%, 33.33% 75.33%, 26% 73%, 39.33% 22%, 33.33% 26%, 31% 32%, 14.33% 35.33%, 18.33% 62.33%, 39.33% 86.33%, 29.33% 69%, 12.33% 30.33%, 29.33% 41.33%, 22.33% 46.33%, 35.33% 27.33%, 22.33% 39.33%, 20.33% 44.33%, 33.33% 56.33%; } .fireworks { display: flex; align-items: center; justify-content: center; flex-basis: 6%; max-width: 70px; height: 100px; position: relative; margin: 1px; } .fireworks:before { content: ""; position: absolute; width: 60%; height: 8px; background: linear-gradient(180deg, #111, #000); border-radius: 5px; border: 1px solid #000; top: -1px; box-shadow: 8px 42px 0 0px #111, -8px 42px 0 0px #111, 8px 42px 0 1px #000, -8px 42px 0 1px #000, 10px 75px 0 0px #111, -10px 75px 0 0px #111, 10px 75px 0 1px #000, -10px 75px 0 1px #000; z-index: 1; } .fireworks:after { --load: 0px; content: ""; position: absolute; width: 80%; height: 100%; z-index: -1; background: linear-gradient(0deg, #fff0 26px, #ff6600dd 0 var(--load) , #fff0 0 100%), linear-gradient(180deg, #010101, #111, #111, #010101); border-radius: 50% 50% 50% 50%/100% 100% 40% 40%; border: 1px solid #000; transition: --load 2s ease 0s; } .fireworks:has(input:checked):after { animation: reloading calc(var(--sp) * 5) ease 0s; } @keyframes reloading { 0% { --load: 26px; } 100% { --load: 50px; } } .fireworks input { display: none; } .fireworks label { display: flex; align-items: center; align-items: flex-end; justify-content: center; position: absolute; width: 100%; height: 100%; bottom: 0; transition: bottom calc(var(--sp) / 2) ease-out 0s; cursor: pointer; margin: 5px; opacity: 1; } .fireworks label:before { content: "LAUNCH"; font-family: Arial, sans-serif; font-size: 1vw; z-index: 1; padding: 5px 3px; background: #4CAF50; position: absolute; width: calc(100% - 6px); text-align: center; box-sizing: border-box; margin: 0 0 22px 0; height: 21px; line-height: 12px; border-radius: 2px; color: #0002; text-shadow: 0 -1px 1px #000, 0 0px 1px #fff8; } .fireworks:hover label:before { background: #369; color: #fff; } input:checked + label:before { animation: reset-fireworks-txt calc(var(--sp) * 3.25) ease-out 0s; animation-fill-mode: forwards; } .fireworks label span { border: 1px solid red; display: flex; background: orange; width: 5px; height: 5px; border-radius: 100%; position: absolute; top: 0; box-shadow: 0 0 15px -3px orange, 0 3px 2px -1px red; } /*fireworks*/ @for $f from 1 through 12 { .fireworks:nth-child(#{$f}) { label span { filter: hue-rotate(random(360) * 1deg); transform: scale(1.2); filter: hue-rotate(random(360) * 1deg) blur(0.25px); } input:checked + label { bottom: random(40) + 30 * 1vh; animation: reset-fireworks calc(var(--sp) * 3) ease calc(calc(var(--sp) / 4) * 3); animation-fill-mode: forwards; /*sparks*/ @for $s from 1 through 70 { & > span:nth-child(#{$s}) { transform: translateX(random(360) - random(360) + ($s) * 1.5px) translateY(random(360) - random(360) * 1.5px) scale(0.75); transition: transform var(--sp) ease-out calc(var(--sp) / 2), opacity var(--sp) ease calc(var(--sp) * 0.01 * #{$s}), box-shadow calc(var(--sp) * 1.5) ease calc(var(--sp) / 1.5); opacity: 0; /*rainbow fireworks*/ /*filter: hue-rotate(random(360) * 1deg) blur(0px);*/ box-shadow: 0 0 25px 5px orange, 0 -5px 1px -1px red, 0 -10px 1px -1px red, 0 -15px 1px -1px red, 0 -20px 1px -1px red, 0 -25px 1px -2px red, 0 -30px 2px -2px red, 0 -35px 2px -2px red, 0 -40px 2px -3px red, 0 -45px 2px -3px red; } } } } } @keyframes reset-fireworks { 0% { filter: hue-rotate(random(360) * 1deg); } 85%, 100% { bottom: 0; transition: bottom var(--sp) ease-out var(--sp); } } @keyframes reset-fireworks-txt { 0% , 99% { color: #fff0; background: #fff0; text-shadow: none; } 100% { content: "RELOAD"; color: #fffd; background: #f44336; text-shadow: 0 1px 0 #0008; } } @media screen and (max-width: 680px) { .fireworks { flex-basis: 10%; font-size: 12vw; } .fireworks label:before { font-size: 1.5vw; } .fireworks:nth-child(n+9) { display: none; } } /*** Launch All Button ***/ /*** Only used if the javascript is uncomment ***/ #launch-all { position: absolute; top: 50px; cursor: pointer; padding: 1vmin; font-weight: bold; background: #0008; color: #fff; border: 2px solid #fff; border-radius: 5px; } #launch-all:hover { background: #fffc; color: #222; border-color: #222; } </style> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/sass.sync.js"></script> <script> const styleEls = document.querySelectorAll('style'); styleEls.forEach(styleEl => { const type = styleEl.getAttribute('type'); if (type == 'text/scss') { Sass.compile(styleEl.innerHTML, function(result) { if (result.status == 0) { const newStyleEl = document.createElement('style'); newStyleEl.textContent = result.text document.head.appendChild(newStyleEl); } }) } }); </script> </head> <body > <div class="fireworks"> <input type="checkbox" id="check-0"/> <label for="check-0"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span> </label> </div> <div class="fireworks"> <input type="checkbox" id="check-1"/> <label for="check-1"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span> </label> </div> <div class="fireworks"> <input type="checkbox" id="check-2"/> <label for="check-2"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span> </label> </div> <div class="fireworks"> <input type="checkbox" id="check-3"/> <label for="check-3"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span> </label> </div> <div class="fireworks"> <input type="checkbox" id="check-4"/> <label for="check-4"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><.........完整代码请登录后点击上方下载按钮下载查看
网友评论0