css+svg实现熔岩灯动画效果代码
代码语言:html
所属分类:动画
代码描述:css+svg实现熔岩灯动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --height: 400px; --drop-color: #3ee02e; --lamp-color: #34a4d296; } body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: radial-gradient(50vh 100vh ellipse, #037b03dd, #000 60%); overflow: hidden; } .lamp { height: var(--height); width: calc(var(--height) * 0.45); position: relative; display: flex; flex-direction: column; align-items: center; } .lamp .top { height: 15%; width: 50%; background: linear-gradient(90deg, #bebebe 15%, #fdfdfd 30%, #bebebe 40%, #878787 48% 52%, #bebebe 58%, #fdfdfd 65% 70%, #bebebe 80%); border-radius: 50% 50% 10% 10%/15% 15% 3% 3%; -webkit-clip-path: polygon(7% 0%, 93% 0%, 100% 100%, 0% 100%); clip-path: polygon(7% 0%, 93% 0%, 100% 100%, 0% 100%); } .lamp .center { height: 53%; width: 70%; background: linear-gradient(#0003 10%, #0000 30% 95%, #fff3 100%), linear-gradient(90deg, #0000 20%, #fff5 50%, #0000 80%), radial-gradient(calc(var(--height) * 0.21) calc(var(--height) * 0.48) at center 35%, #0000 60%, #fff4 90%) var(--lamp-color); position: relative; top: -1.5%; border-top: calc(var(--height) * 0.006) solid #666; border-bottom: calc(var(--height) * 0.006) solid #666; border-radius: 50% 50% 50% 50%/8% 8% 8% 8%; -webkit-clip-path: polygon(16% 0%, 84% 0%, 100% 70%, 86% 100%, 14% 100%, 0 70%); clip-path: polygon(16% 0%, 84% 0%, 100% 70%, 86% 100%, 14% 100%, 0 70%); overflow: hidden; z-index: 1; } .lamp .center .lava-container { width: 70%; height: 120%; margin: 0 15%; position: relative; top: -10%; overflow: hidden; box-shadow: inset 0 calc(var(--height) * 0.053) 0 var(--drop-color), inset 0 calc(var(--height) * -0.053) 0 var(--drop-color); filter: url("#goo") drop-shadow(0 0 3px #fff6) drop-shadow(0 1px 2px #fff6); box-sizing: border-box; border-radius: 50% 50% 50% 50%/3% 3% 1% 1%; } .lamp .center .lava-container .drop { height: calc(var(--height) * 0.07); width: calc(var(--height) * 0.07); border-radius: 50%; background: linear-gradient(#0001 10%, #0000 70%, #fff1) var(--drop-color); position: absolute; top: -100%; -webkit-animation: lava-drip 12s linear infinite alternate; animation: lava-drip 12s linear infinite alternate; } .lamp .center .lava-container .drop:nth-child(2) { height: calc(var(--height) * 0.08); width: calc(var(--height) * 0.09); left: 7%; -webkit-animation-delay: 1s; animation-delay: 1s; } .lamp .center .lava-container .drop:nth-child(3) { height: calc(var(--height) * 0.08); width: calc(var(--height) * 0.06); left: 60%; -webkit-animation-delay: 2.2s; animation-delay: 2.2s; } .lamp .center .lava-container .drop:nth-child(4) { height: calc(var(--height) * 0.1); width: calc(var(--height) * 0.06); left: 50%; -webkit-animation-delay: 3s; animation-delay: 3s; } .lamp .center .lava-container .drop:nth-child(5) { height: calc(var(--height) * 0.07); width: calc(var(--height) * 0.05); left: 10%; -webkit-animation-delay: 4.2s; animation-delay: 4.2s; } .lamp .center .lava-container .drop:nth-child(6) { height: calc(var(--height) * 0.07); width: calc(var(--height) * 0.05); left: 70%; -webkit-animation-delay: 4.8s; animation-delay: 4.8s; } .lamp .center .lava-container .drop:nth-child(7) { height: calc(var(--height) * 0.06); width: calc(var(--height) * 0.04); left: 40%; -webkit-animation-delay: 5.6s; animation-delay: 5.6s; } .lamp .center .lava-container .drop:nth-child(8) { height: calc(var(--hei.........完整代码请登录后点击上方下载按钮下载查看
网友评论0