split实现多种文字跳动动画
代码语言:html
所属分类:动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> - Animated Verbs</title> <link href="https://fonts.googleapis.com/css?family=Lexend+Deca&display=swap" rel="stylesheet"> <style> * { box-sizing: border-box; } html, body { height: 100%; } .container { max-height: 100vh; overflow-y: scroll; -webkit-perspective: 1000px; perspective: 1000px; position: relative; -ms-scroll-snap-type: y mandatory; scroll-snap-type: y mandatory; -webkit-overflow-scrolling: touch; } .headline { align-items: center; display: flex; font-family: 'Lexend Deca', sans-serif; font-weight: 700; font-size: calc(1rem + 15vmin); height: 100vh; justify-content: center; scroll-snap-align: start; width: 100vw; } .headline:nth-child(1) { background-color: #f9ca24; } .headline:nth-child(2) { background-color: #3498db; } .headline:nth-child(3) { background-color: #ff7979; } .headline:nth-child(4) { background-color: #1abc9c; } .headline:nth-child(5) { background-color: #e74c3c; } .headline:nth-child(6) { background-color: #f8c291; } .char { -webkit-animation-name: var(--name); animation-name: var(--name); -webkit-animation-duration: var(--speed); animation-duration: var(--speed); -webkit-animation-delay: var(--delay); animation-delay: var(--delay); -webkit-animation-timing-function: var(--ease); animation-timing-function: var(--ease); -webkit-animation-direction: var(--direction, normal); animation-direction: var(--direction, normal); -webkit-animation-iteration-count: infinite; animation-iteration-count: infinite; display: inline-block; position: relative; -webkit-transform-origin: 50% 100%; transform-origin: 50% 100%; } .headline--fall .char { --name: fall; --speed: 600ms; --delay: calc(var(--char-index) * -0.05s); --ease: cubic-bezier(0.165, 0.44, 0.64, 1); } @-webkit-keyframes fall { 0% { -webkit-transform: rotateY(-25deg); transform: rotateY(-25deg); } 25% { -webkit-transform: translateY(2%) rotateY(25deg); transform: translateY(2%) rotateY(25deg); } 50% { -webkit-transform: rotateY(-25deg); transform: rotateY(-25deg); } 75% { -webkit-transform: translateY(4%) rotateY(25deg); transform: translateY(4%) rotateY(25deg); } 100% { -webkit-transform: rotateY(-25deg); transform: rotateY(-25deg); } } @keyframes fall { 0% { -webkit-transform: rotateY(-25deg); transform: rotateY(-25deg); } 25% { -webkit-transform: translateY(2%) rotateY(25deg); transform: translateY(2%) rotateY(25deg); } 50% { -webkit-transform: rotateY(-25deg); transform: rotateY(-25deg); } 75% { -webkit-transform: translateY(4%) rotateY(25deg); transform: translateY(4%) rotateY(25deg); } 100% { -webkit-transform: rotateY(-25deg); transform: rotateY(-25deg); } } .headline--flip .char { --name: flip; --speed: 4000ms; --delay: calc(var(--char-index) * 0.075s); --ease: linear; } @-webkit-keyframes flip { 5% { -webkit-transform: rotateX(1turn); transform: rotateX(1turn); } 10% { -webkit-transform: rotateX(2turn); transform: rotateX(2turn); } 20% { -webkit-transform: rotateX(3turn); transform: rotateX(3turn); } 40% { -webkit-transform: rotateX(4turn); transform: rotateX(4turn); } 70%, 100% { -webkit-transform: rotateX(5turn); transform: rotateX(5turn); } } @keyframes flip { 5% { -webkit-transform: rotateX(1turn); transform: rotateX(1turn); } 10% { -webkit-transform: rotateX(2turn); transform: rotateX(2turn); } 20% { -webkit-transform: rotateX(3turn); transform: rotateX(3turn); } 40% { -webkit-transform: rotateX(4turn); transform: rotateX(4turn); } 70%, 100% { -webkit-transform: rotateX(5turn); transform: rotateX(5turn); } } .headline--float .char { --name: float; --speed: 2200ms; --delay: calc(var(--char-index) * -0.5s); --ease: ease-in-out; --direction: alternate; } .headline--float .char:nth-child(2n) { --name: float-alt; } @-webkit-keyframes float { from { -webkit-transform: translate(2%, -10%) rotate(-1deg); transform: translate(2%, -10%) rotate(-1deg); } to { -webkit-transform: translate(-2%, 5%) rotate(3deg); transform: translate(-2%, 5%) rotate(3deg); } } @keyframes float { from { -webkit-transform: translate(2%, -10%) rotate(-1deg); transform: translate(2%, -10%) rotate(-1deg); } to { -webkit-transform: translate(-2%, 5%) rotate(3deg); transform: translate(-2%, 5%) rotate(3deg); } } @-webkit-keyframes float-alt { from { -webkit-transform: translate(0%, -5%) rotate(-1deg); transform: translate(0%, -5%) rotate(-1deg); } to { -webkit-transform: translate(2%, 10%) ro.........完整代码请登录后点击上方下载按钮下载查看
网友评论0