svg试管冒泡动画效果
代码语言:html
所属分类:动画
代码描述:试管冒泡动画效果,通过svg结合js实现
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> :root { --primary: #a231ff; --primary-dark: #6a22d6; --grey-light: #F5F6FA; --grey: #645c6b; --white: #ffffff; } *, *::before, *::after { margin: 0; padding: 0; box-sizing: inherit; } html { box-sizing: border-box; font-size: 62.5%; overflow-y: scroll; } .container { min-height: 100vh; display: flex; justify-content: center; align-items: center; background: var(--grey-light); } .test-tube { display: flex; flex-direction: column; justify-content: center; align-items: center; } .line-top { height: .6rem; width: 10rem; margin-bottom: -.6rem; background: var(--grey); z-index: 500; position: relative; } .line-top::before, .line-top::after { content: ''; position: absolute; height: .6rem; width: 1.4rem; background: var(--grey); top: 2.4rem; border-radius: 1rem; } .line-top::before { left: -.4rem; } .line-top::after { left: 9rem; } .line-top__line1, .line-top__line2 { position: absolute; top: 12rem; left: 1.8rem; height: 10rem; width: .6rem; background: var(--white); opacity: .5; border-radius: 1rem; } .line-top__line2 { top: 10rem; height: 1.5rem; } .top { width: 14.2rem; height: 3rem; margin-bottom: -.7rem; border-radius: 4rem; border: 0.6rem solid var(--grey); z-index: 100; } .liquid { width: 7.8rem; height: 20rem; margin-bottom: -24.7rem; margin-top: 4.8rem; display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; z-index: 300; } .liquid__bottom { height: 18rem; width: inherit; border-bottom-left-radius: 8rem; border-bottom-right-radius: 8rem; background: var(--primary); background: linear-gradient(360deg, var(--primary-dark) 0%, var(--primary) 100%); } .tube { width: 10.2rem; height: 25.8rem; border-bottom-left-radius: 8rem; border-bottom-right-radius: 8rem; border: 0.6rem solid var(--grey); border-top: 0.6rem solid var(--grey-light); z-index: 200; } .color:nth-child(1) { width: 7px; height: 7px; bottom: 15px; left: 45px; border-radius: 50%; position: absolute; animation: move-1 5s infinite; animation-delay: -0.2s; z-index: 400; } @keyframes move-1 { 100% { transform: translateY(-21rem); } } .color:nth-child(2) { width: 12px; height: 12px; bottom: 32px; left: 35px; border-radius: 50%; position: absolute; animation: move-2 5s infinite; animation-delay: -0.4s; z-index: 400; } @keyframes move-2 { 100% { transform: translateY(-7rem); } } .color:nth-child(3) { width: 11px; height: 11px; bottom: 61px; left: 46px; border-radius: 50%; position: absolute; animation: move-3 5s infinite; animation-delay: -0.6s; z-index: 400; } @keyframes move-3 { 100% { transform: translateY(-7rem); } } .color:nth-child(4) { width: 9px; height: 9px; bottom: 45px; left: 18px; border-radius: 50%; position: absolute; animation: move-4 5s infinite; animation-delay: -0.8s; z-index: 400; } @keyframes move-4 { 100% { transform: translateY(-26rem); } } .color:nth-child(5) { width: 12px; height: 12px; bottom: 50px; left: 11px; border-radius: 50%; position: absolute; animation: move-5 5s infinite; animation-delay: -1s; z-index: 400; } @keyframes move-5 { 100% { transform: translateY(-21rem); } } .color:nth-child(6) { width: 11px; height: 11px; bottom: 17px; left: 19px; border-radius: 50%; position: absolute; animation: move-6 5s infinite; animation-delay: -1.2s; z-index: 400; } @keyframes move-6 { 100% { transform: translateY(-23rem); } } .color:nth-child(7) { width: 9px; height: 9px; bottom: 29px; left: 24px; border-radius: 50%; position: absolute; animation: move-7 5s infinite; animation-delay: -1.4s; z-index: 400; } @keyframes move-7 { 100% { transform: translateY(-9rem); } } .color:nth-child(8) { width: 11px; height: 11px; bottom: 18px; left: 51px; border-radius: 50%; position: absolute; animation: move-8 5s infinite; animation-delay: -1.6s; z-index: 400; } @keyframes move-8 { 100% { transform: translateY(-22rem); } } .color:nth-child(9) { width: 12px; height: 12px; bottom: 23px; left: 21px; border-radius: 50%; position: absolute; animation: move-9 5s infinite; animation-delay: -1.8s; z-index: 400; } @keyframes move-9 { 100% { transform: translateY(-10rem); } } .color:nth-child(10) { width: 11px; height: 11px; bottom: 18px; left: 39px; border-radius: 50%; position: absolute; animation: move-10 5s infinite; animation-delay: -2s; z-index: 400; } @keyframes move-10 { 100% { transform: translateY(-5rem); } } .color:nth-child(11) { width: 8px; height: 8px; bottom: 40px; left: 15px; border-radius: 50%; position: absolute; animation: move-11 5s infinite; animation-delay: -2.2s; z-index: 400; } @keyframes move-11 { 100% { transform: translateY(-16rem); } } .color:nth-child(12) { width: 9px; height: 9px; bottom: 60px; left: 24px; border-radius: 50%; position: absolute; animation: move-12 5s infinite; animation-delay: -2.4s; z-index: 400; } @keyframes move-12 { 100% { transform: translateY(-11rem); } } .color:nth-child(13) { width: 10px; height: 10px; bottom: 43px; left: 31px; border-radius: 50%; position: absolute; animation: move-13 5s infinite; animation-delay: -2.6s; z-index: 400; } @keyframes move-13 { 100% { transform: translateY(-4rem); } } .color:nth-child(14) { width: 10px; height: 10px; bottom: 70px; left: 13px; border-radius: 50%; position: absolute; animation: move-14 5s infinite; animation-delay: -2.8s; z-index: 400; } @keyframes move-14 { 100% { transform: translateY(-30rem); } } .color:nth-child(15) { width: 10px; height: 10px; bottom: 15px; left: 1.........完整代码请登录后点击上方下载按钮下载查看
网友评论0