css实现三角形内彩色变换动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现三角形内彩色变换动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #000; overflow: hidden; --offset: 0s; } body .hover { position: absolute; z-index: 999; width: 100vw; height: 5vh; top: 0; left: 0; } body .hover:nth-of-type(1) { top: 0%; } body .hover:nth-of-type(1):hover ~ #kaleidoscope { --offset: -0.1s; } body .hover:nth-of-type(2) { top: 5%; } body .hover:nth-of-type(2):hover ~ #kaleidoscope { --offset: -0.2s; } body .hover:nth-of-type(3) { top: 10%; } body .hover:nth-of-type(3):hover ~ #kaleidoscope { --offset: -0.3s; } body .hover:nth-of-type(4) { top: 15%; } body .hover:nth-of-type(4):hover ~ #kaleidoscope { --offset: -0.4s; } body .hover:nth-of-type(5) { top: 20%; } body .hover:nth-of-type(5):hover ~ #kaleidoscope { --offset: -0.5s; } body .hover:nth-of-type(6) { top: 25%; } body .hover:nth-of-type(6):hover ~ #kaleidoscope { --offset: -0.6s; } body .hover:nth-of-type(7) { top: 30%; } body .hover:nth-of-type(7):hover ~ #kaleidoscope { --offset: -0.7s; } body .hover:nth-of-type(8) { top: 35%; } body .hover:nth-of-type(8):hover ~ #kaleidoscope { --offset: -0.8s; } body .hover:nth-of-type(9) { top: 40%; } body .hover:nth-of-type(9):hover ~ #kaleidoscope { --offset: -0.9s; } body .hover:nth-of-type(10) { top: 45%; } body .hover:nth-of-type(10):hover ~ #kaleidoscope { --offset: -1s; } body .hover:nth-of-type(11) { top: 50%; } body .hover:nth-of-type(11):hover ~ #kaleidoscope { --offset: -1.1s; } body .hover:nth-of-type(12) { top: 55%; } body .hover:nth-of-type(12):hover ~ #kaleidoscope { --offset: -1.2s; } body .hover:nth-of-type(13) { top: 60%; } body .hover:nth-of-type(13):hover ~ #kaleidoscope { --offset: -1.3s; } body .hover:nth-of-type(14) { top: 65%; } body .hover:nth-of-type(14):hover ~ #kaleidoscope { --offset: -1.4s; } body .hover:nth-of-type(15) { top: 70%; } body .hover:nth-of-type(15):hover ~ #kaleidoscope { --offset: -1.5s; } body .hover:nth-of-type(16) { top: 75%; } body .hover:nth-of-type(16):hover ~ #kaleidoscope { --offset: -1.6s; } body .hover:nth-of-type(17) { top: 80%; } body .hover:nth-of-type(17):hover ~ #kaleidoscope { --offset: -1.7s; } body .hover:nth-of-type(18) { top: 85%; } body .hover:nth-of-type(18):hover ~ #kaleidoscope { --offset: -1.8s; } body .hover:nth-of-type(19) { top: 90%; } body .hover:nth-of-type(19):hover ~ #kaleidoscope { --offset: -1.9s; } body .hover:nth-of-type(20) { top: 95%; } body .hover:nth-of-type(20):hover ~ #kaleidoscope { --offset: -2s; } body:before, body:after { content: ""; position: absolute; width: 100%; height: 50%; top: calc(50% + 75px); z-index: 10; -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); } body:after { -webkit-backdrop-filter: none; backdrop-filter: none; height: 100%; top: 0; background: linear-gradient(to right, #000 calc(50% - 180px), transparent calc(50% - 180px), transparent calc(50% + 180px), #000 calc(50% + 180px)); } body #svg { position: absolute; } body #kaleidoscope { width: 500px; height: 400px; position: absolute; top: calc(50% - 325px); -webkit-box-reflect: below 0px linear-gradient(rgba(0, 0, 0, 0.25) 50%, rgba(0, 0, 0, 0.05)); overflow: hidden; } body #kaleidoscope > div { filter: url(#pixelate); width: 300px; height: 600px; position: absolute; overflow: hidden; left: 50%; background: linear-gradient(to right, #03001e, #7303c0, #ec38bc, #fdeff9, #ec38bc, #7303c0, #03001e); -webkit-box-reflect: left; transform: scale(0.75); transform-origin: left; top: 35px; } body #kaleidoscope > div:before, body #kaleidoscope > div:after { content: ""; position: absolute; width: 100%; height: 100%; background: #000; z-index: 9; border-radius: 0 500px 500px 0; -webkit-mask: linear-gradient(57.5deg, transparent 50%, #000 50%) 0% -100px/95% 115%, linear-gradient(to left, #000 25px, transparent 25px), linear-gradient(to top, #000 175px, transparent 100px); } body #kaleidoscope > div:after { -webkit-mask: none; mask: none; background: transparent; box-shadow: 0 0 0 150px #000; transform: scale(0.99); transform-origin: left; } body #kaleidoscope .wrap { width: 600px; height: 300px; left: calc(50% - 450px); top: calc(50% - 300px); position: absolute; transform-origin: 50% 100%; -webkit-animation: spin2 10s ease-in-out infinite alternate; animation: spin2 10s ease-in-out infinite alternate; -webkit-box-reflect: below; } @-webkit-keyframes spin2 { to { transform: rotate(180deg); } } @keyframes spin2 { to { transform: rotate(180deg); } } body #kaleidoscope .wrap:nth-of-type(2) .mask { -webkit-mask: conic-gradient(from -98.5deg at 50% 100%, #000 5%, transparent 5%, transparent 10%, #000 10%, #000 15%, transparent 15%, transparent 20%, #000 20%, #000 25%, transparent 25%, transparent 30%, #000 30%, #000 35%, transparent 35%, transparent 40%, #000 40%, #000 45%, transparent 45%, transparent 50%, #000 50%, #000 55%); } body #kaleidoscope .wrap:nth-of-type(2) .mask .inner { animation-direction: reverse; } body #kaleidoscope .wrap:nth-of-type(2) .mask .inner .cell:before { border-radius: 100%; } body #kaleidoscope .wrap .mask { position: absolute; width: 100%; height: 100%; left: 0; top: 0; -webkit-mask: conic-gradient(from -98.5deg at 50% 100%, transparent 4%, #000 4%, #000 11%, transparent 10%, transparent 14%, #000 14%, #000 21%, transparent 20%, transparent 24%, #000 24%, #000 31%, transparent 30%, transparent 34%, #000 34%, #000 42%, transparent 40%, transparent 44%, #000 44%, #000 51%, transparent 50%, transparent 55%); } body #kaleidoscope .wrap .mask .inner { position: absolute; width: 100%; height: 200%; border-radius: 100%; top: 0; left: 0; overflow: hidden; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); -webkit-animation: spin 20s linear infinite; animation: spin 20s linear infinite; } @-webkit-keyframes spin { to { transform: rotate(360deg); } } @keyframes spin { to { transform: rotate(360deg); } } body #kaleidoscope .wrap .mask .inner .cell { position: relative; } body #kaleidoscope .wrap .mask .inner .cell:nth-of-type(1):before { -webkit-animation-delay: calc(-0.1818181818s + var(--offset)); animation-delay: calc(-0.1818181818s + var(--offset)); } body #kaleidoscope .wrap .mask .inner .cell:nth-of-type(2):before { -webkit-animation-delay: calc(-0.3636363636s + var(--offset)); animation-delay: calc(-0.3636363636s + var(--offset)); } body #kaleidoscope .wrap .mask .inner .cell:nth-of-type(3):before { -webkit-animation-delay: calc(-0.5454545455s + var(--offset));.........完整代码请登录后点击上方下载按钮下载查看
网友评论0