div+css实现三维钻石球旋转动画效果代码
代码语言:html
所属分类:动画
代码描述:div+css实现三维钻石球旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> input { display: none; } body { margin: 0; height: 100vh; background-image: linear-gradient(to bottom right, transparent, #333); font-size: .6vmin; } body * { position: absolute; } .wrapper { position: absolute; inset: 0; background-image: linear-gradient(to bottom left, #000, #011, #303); display: grid; animation: hue 2s ease-in-out infinite alternate; } @keyframes hue { 0% { filter: saturate(4) contrast(1.5) hue-rotate(180deg); } 100% { filter: saturate(5) contrast(2) hue-rotate(360deg); } } .playBtn { display: block; width: 30em; aspect-ratio: 1; background-color: black; align-self: end; margin: 10em; clip-path: polygon(0 0, 40% 20%, 40% 20%, 60% 30%, 60% 30%, 100% 50%, 100% 50%, 0 100%); transition: all .5s ease-in-out; transform-origin: 0 100%; } .playBtn:hover { scale: 1.2; } #playPause:checked ~ .wrapper .playBtn { clip-path: polygon(0 0, 40% 0%, 40% 100%, 60% 100%, 60% 0, 100% 0, 100% 100%, 0 100%); } #playPause:not(:checked) ~ .wrapper, #playPause:not(:checked) ~ .wrapper :is(.pivot, .starHedron, .triangle), #playPause:not(:checked) ~ .wrapper .pentagon::before { animation-play-state: paused; } .scene { place-self: center; width: 100em; aspect-ratio: 1; perspective: 250em; } .scene * { transform-style: preserve-3d; } .pivot, .starHedron { inset: 0; } .pivot { animation: wobble 8s ease-in-out alternate infinite; } @keyframes wobble { 0% { rotate: x -30deg; } 100% { rotate: x 30deg; } } .starHedron { display: grid; place-items: center; animation: spin 9s linear infinite; } @keyframes spin { 0% { rotate: y 1deg; } 100% { rotate: y 361deg; } } .pentagon { --pentaW: calc(sin(atan(1/(cos(36deg) + .5))) * 100); width: calc(var(--pentaW)*1em); aspect-ratio: 1; --pushZ: calc(cos(atan(1/(cos(36deg) + .5))) * 50); display: grid; } .pentagon::before, .triangle { background-image: linear-gradient(23deg, #ffeeff02 20%, #eeffff28, #ffe1, #efea 85%); background-size: 500% 500%; animation: shimmer 1s linear alternate infinite; } .pentagon::before { content: ''; position: absolute; inset: 0; clip-path: polygon( calc(50%*(1 + sin(72deg*0))) calc(50%*(1 + cos(72deg*0))), calc(50%*(1 + sin(72deg*1))) calc(50%*(1 + cos(72deg*1))), calc(50%*(1 + sin(72deg*2))) calc(50%*(1 + cos(72deg*2))), calc(50%*(1 + sin(72deg*3))) calc(50%*(1 + cos(72deg*3))), calc(50%*(1 + sin(72deg*4))) calc(50%*(1 + cos(72deg*4))), calc(50%*(1 + cos(36deg)*sin(72deg*4.5))) calc(50%*(1 + cos(36deg)*cos(72deg*4.5))), calc(50%*(1 + cos(36deg)*sin(72deg*3.5))) calc(50%*(1 + cos(36deg)*cos(72deg*3.5))), calc(50%*(1 + cos(36deg)*sin(72deg*2.5))) calc(50%*(1 + cos(36deg)*cos(72deg*2.5))), calc(50%*(1 + cos(36deg)*sin(72deg*1.5))) calc(50%*(1 + cos(36deg)*cos(72deg*1.5))), calc(50%*(1 + cos(36deg)*sin(72deg*.5))) calc(50%*(1 + cos(36deg)*cos(72deg*.5))), calc(50%*(1 + cos(36deg)*sin(72deg*4.5))) calc(50%*(1 + cos(36deg)*cos(72deg*4.5))) ); padding: 1px; animation-delay: calc(-.415s*var(--step)); filter: hue-rotate(calc(var(--step)*61deg)); } .side.........完整代码请登录后点击上方下载按钮下载查看
网友评论0