纯css实现一群气球上升动画
代码语言:html
所属分类:动画
代码描述:纯css实现一群气球上升动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> :root { --desired-size: 20; --coefficient: 1vmin; --size: calc(var(--desired-size) * var(--coefficient)); --primary-color: hsl(320, 100%, 50%); --chord: hsl(45, 100%, 40%); --shine: hsla(0, 0%, 100%, 0.75); } body { min-height: 100vh; display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: center; background: hsl(180, 100%, 95%); } .balloon { --primary-color: hsla(var(--h, 0), 100%, 50%, 0.8); --size: calc(var(--s, 10) * var(--coefficient)); height: calc(1.2 * var(--size)); width: var(--size); background: var(--primary-color); border-radius: 50% 50% 50% 50% / 45% 45% 55% 55%; position: absolute; top: 50%; left: calc(var(--x, 50) * 1%); -webkit-animation: float calc(var(--d, 1) * 1s) calc(var(--delay, 0) * -1s) infinite linear both; animation: float calc(var(--d, 1) * 1s) calc(var(--delay, 0) * -1s) infinite linear both; } .balloon:before { content: ''; position: absolute; width: 20%; height: 30%; background: blue; top: 8%; left: 16%; border-radius: 50%; -webkit-transform: rotate(40deg); transform: rotate(40deg); background: var(--shine); } .balloon__handle { width: 2%; height: 60%; background: var(--chord); top: 100%; left: 50%; -webkit-transform: translate(-50%, 0); transform: translate(-50%, 0); position: absolute; } .balloon__handle:before, .balloon__handle:after { content: ''; position: absolute; height: 5%; -webkit-transform: translate(-50%, 0); transform: translate(-50%, 0); border-radius: 25% / 50%; left: 50%; } .balloon__handle:before { top: 0; background: var(--chord); width: 500%; } .balloon__handle:after { top: 5%; background: var(--primary-color); width: 700%; } @-webkit-keyframes float { from { -webkit-transform: translate(-50%, -50%) translate(0, 100vh); transform: translate(-50%, -50%) translate(0, 100vh); } to { -webkit-transform: translate(-50%, -50%) translate(0, -100vh); transform: translate(-50%, -50%) translate(0, -100vh); } } @keyframes float { from { -webkit-transform: translate(-50%, -50%) translate(0, 100vh); transform: translate(-50%, -50%) translate(0, 100vh); } to { -webkit-transform: translate(-50%, -50%) translate(0, -100vh); transform: translate(-50%, -50%) translate(0, -100vh); } } </style> </head> <body translate="no"> <div class="balloon" style="--x: 18; --h: 232; --s: 12; --d: 4; --delay: 2;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 68; --h: 67; --s: 45; --d: 3; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 45; --h: 302; --s: 42; --d: 9; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 75; --h: 54; --s: 16; --d: 3; --delay: 3;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 31; --h: 243; --s: 4; --d: 2; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 86; --h: 328; --s: 39; --d: 1; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 99; --h: 195; --s: 3; --d: 4; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 54; --h: 311; --s: 16; --d: 6; --delay: 3;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 86; --h: 287; --s: 26; --d: 6; --delay: 4;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 93; --h: 72; --s: 4; --d: 5; --delay: 5;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 94; --h: 173; --s: 43; --d: 3; --delay: 3;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 43; --h: 25; --s: 18; --d: 3; --delay: 3;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 52; --h: 242; --s: 49; --d: 7; --delay: 5;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 26; --h: 163; --s: 24; --d: 6; --delay: 6;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 93; --h: 21; --s: 15; --d: 6; --delay: 5;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 46; --h: 157; --s: 35; --d: 9; --delay: 8;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 48; --h: 349; --s: 17; --d: 8; --delay: 5;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 55; --h: 122; --s: 5; --d: 3; --delay: 2;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 82; --h: 335; --s: 42; --d: 9; --delay: 6;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 61; --h: 216; --s: 48; --d: 2; --delay: 2;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 97; --h: 330; --s: 4; --d: 6; --delay: 3;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 65; --h: 91; --s: 50; --d: 10; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 42; --h: 165; --s: 37; --d: 10; --delay: 4;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 48; --h: 22; --s: 40; --d: 1; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 78; --h: 169; --s: 30; --d: 10; --delay: 10;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 35; --h: 189; --s: 17; --d: 1; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 76; --h: 94; --s: 39; --d: 3; --delay: 3;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 35; --h: 128; --s: 19; --d: 6; --delay: 3;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 29; --h: 215; --s: 39; --d: 8; --delay: 5;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 73; --h: 83; --s: 20; --d: 1; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 49; --h: 17; --s: 45; --d: 10; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 32; --h: 144; --s: 17; --d: 9; --delay: 9;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 36; --h: 247; --s: 23; --d: 2; --delay: 2;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 72; --h: 194; --s: 3; --d: 8; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 81; --h: 44; --s: 18; --d: 4; --delay: 2;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 50; --h: 319; --s: 26; --d: 4; --delay: 4;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 96; --h: 49; --s: 29; --d: 2; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 28; --h: 183; --s: 20; --d: 4; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 1; --h: 281; --s: 50; --d: 10; --delay: 1;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 10; --h: 204; --s: 43; --d: 10; --delay: 8;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 98; --h: 166; --s: 12; --d: 8; --delay: 2;"> <div class="balloon__handle"></div> </div> <div class="balloon" style="--x: 42; --h: 70; --s: 8; --d: 5; --delay: 2;"> <div class="balloon__handle"></div> </div> <div class="balloon.........完整代码请登录后点击上方下载按钮下载查看
网友评论0