css实现一个爱心花圈转动动画效果代码
代码语言:html
所属分类:动画
代码描述:css实现一个爱心花圈转动动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<html lang="en"> <head> <meta charset="UTF-8"> <style> html, body { height: 100%; } body { display: grid; grid-template-rows: repeat(7, 1fr); place-items: center; overflow: hidden; } body > * { grid-column: 1; } .hover-zone { grid-row: var(--i); width: 100%; height: 100%; z-index: 1; } .hover-zone-1:hover ~ .scene { --rotate: -30deg; } .hover-zone-2:hover ~ .scene { --rotate: -20deg; } .hover-zone-3:hover ~ .scene { --rotate: -10deg; } .hover-zone-4:hover ~ .scene { --rotate: 0deg; } .hover-zone-5:hover ~ .scene { --rotate: 10deg; } .hover-zone-6:hover ~ .scene { --rotate: 20deg; } .hover-zone-7:hover ~ .scene { --rotate: 30deg; } .scene { grid-row: 1 / -1; display: grid; grid-template-areas: "hearts"; place-items: center; perspective: 50em; transition: transform 1s ease-out; transform: translateY(-50%) rotateX(var(--rotate, 0deg)); transform-style: preserve-3d; pointer-events: none; } .heart-container { --amount: calc(100 / var(--count) * var(--i)); --size: 10vmin; grid-area: hearts; width: var(--size); height: var(--size); transform-style: preserve-3d; -webkit-animation: rotate 10s calc(var(--amount) * -0.1s) linear infinite; animation: rotate 10s calc(var(--amount) * -0.1s) linear infinite; } .heart { overflow: visible; width: 100%; fill: var(--color); transform: rotateY(90deg); -webkit-animation: jump 1s calc(var(--amount) * -0.01s) ease-in-out infinite, color 1s calc(var(--amount) * -0.02s) ease-in-out infinite; animation: jump 1s calc(var(--amount) * -0.01s) ease-in-out infinite, color 1s calc(var(--amount) * -0.02s) ease-in-out infinite; } @-webkit-keyframes rotate { from { transform: rotateX(-10deg) rotateY(0) translateX(calc(var(--size) * 4)); } to { transform: rotateX(-10deg) rotateY(1turn) translateX(calc(var(--size) * 4)); } } @keyframes rotate { from { transform: rotateX(-10deg) rotateY(0) translateX(calc(var(--size) * 4)); } to { transform: rotateX(-10deg) rotateY(1turn) translateX(calc(var(--size) * 4)); } } @-webkit-keyframes jump { 0% { transform: rotateY(90deg); } 25% { transform: rotateY(90deg) rotateZ(25deg) translateY(-10%); -webkit-animation-timing-function: linear; animation-timing-function: linear; } 50% { transform: rotateZ(25deg) rotateY(90deg); } 75% { transform: rotateZ(-25deg) rotateY(90deg) translateY(-10%); -webkit-animation-timing-function: linear; animation-timing-function: linear; } 100% { transform: rotateY(90deg); } } @keyframes jump { 0% { transform: rotateY(90deg); } 25% { transform: rotateY(90deg) rotateZ(25deg) translateY(-10%); -webkit-animation-timing-function: linear; animation-timing-function: linear; } 50% { transform: rotateZ(25deg) rotateY(90deg); } 75% { transform: rotateZ(-25deg) rotateY(90deg) translateY(-10%); -webkit-animation-timing-function: linear; animation-timing-function: linear; } 100% { transform: rotateY(90deg); } } @-webkit-keyframes color { 0% { fill: hsl(2, 43%, 75%); } 50% { fill: hsl(2, 80%, 45%); } 100% { fill: hsl(2, 43%, 75%); } } @keyframes color { 0% { fill: hsl(2, 43%, 75%); } 50% { fill: hsl(2, 80%, 45%); } 100% { fill: hsl(2, 43%, 75%); } } </style> </head> <body> <svg xmlns="http://www.w3.org/2000/svg" style="display: none"> <symbol id="heart" viewBox="0 0 250 217"> <path d="M213.1,6.7c-32.4-14.4-73.7,0-88.1,30.6C110.6,4.9,67.5-9.5,36.9,6.7C2.8,22.9-13.4,62.4,13.5,110.9 C33.3,145.1,67.5,170.3,125,217c59.3-46.7,93.5-71.9,111.5-106.1C263.4,64.2,247.2,22.9,213.1,6.7z"></path> </symbol> </svg> <div class="hover-zone hover-zone-1" style="--i: 1"></div> <div class="hover-zone hover-zone-2&q.........完整代码请登录后点击上方下载按钮下载查看
网友评论0