css实现路径动画效果
代码语言:html
所属分类:动画
代码描述:css实现路径动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --alabaster: #FAFAFA; --frangipani: #FFDCB5; --frostee: #EAF7EB; --lemon-chiffon: #F9EEAB; --sundown: #FFB7BC; --white: #FFF; } *, ::after, ::before { box-sizing: border-box; font-family: sans-serif; margin: 0; padding: 0; } body { background-color: var(--alabaster); min-height: 100vh; width: 100%; } .card-container { display: grid; grid-gap: 2rem; grid-template-columns: repeat(auto-fill, minmax(23rem, 1fr)); margin: 0 auto; max-width: 100%; padding: 2rem; width: 55rem; } .card { align-items: center; border-radius: 0.25rem; box-shadow: 2px 3px 4px rgba(0, 0, 0, 0.25); display: flex; height: 23rem; justify-content: center; position: relative; width: 100%; } .ball { background-color: var(--white); border-radius: 50%; height: 3rem; position: absolute; width: 3rem; } /* Square */ .square-card { background-color: var(--frostee); } .square-card::before { animation: shadow 1.6s ease-in-out infinite both; background-color: rgba(0, 0, 0, 0.2); border-radius: 50%; bottom: 2rem; box-shadow: 0 0 0 8px rgba(0, 0, 0, 0.2); content: ''; height: 0.1rem; left: 25%; position: absolute; right: 25%; } .down { animation: down 1.6s ease-in infinite both; bottom: 2rem; position: absolute; } .down .up { animation: up 1.6s ease-in-out infinite both; } .down .up .squeeze { animation: squeeze 1.6s cubic-bezier(0.72, 0.03, 0.28, 0.97) infinite both; transform-origin: 50% 100%; } .down .up .squeeze .rotate-in { animation: rotate-in 1.6s ease-out infinite both; } .down .up .squeeze .rotate-in .rotate-out { animation: rotate-out 1.6s ease-in infinite both; } .square { background-color: var(--white); height: 5rem; width: 5rem; } @keyframes down { 0% { transform: translateY(-10rem); } 20%, 100% { transform: translateY(0); } } @keyframes up { 0%, 75% { transform: translateY(0); } 100% { transform: translateY(-10rem); } } @keyframes squeeze { 0%, 4% { transform: scale(1); } 45% { transform: scale(1.8, 0.4); } 100% { transform: scale(1); } } @keyframes rotate-in { 0% { transform: rotate(-135deg); } 20%, 100% { transform: rotate(0deg); } } @keyframes rotate-out { 0%, 80% { transform: rotate(0); } 100% { transform: rotate(135deg); } } @keyframes shadow { 0%, 100% { transform: scaleX(0.3); } 45%, 50% { transform: scaleX(0.8); } } /* End square */ /* Ball bouncing */ .ball-bouncing { background-color: var(--lemon-chiffon); } .ball-bouncing::before { animation: shadowBouncing 1.2s ease-in infinite; background-color: rgba(0, 0, 0, 0.2); border-radius: 1rem; bottom: 2rem; content: ''; height: 0.15rem; position: absolute; width: 2rem; } .ball-bouncing .ball { animation: ballBouncing 1.2s ease-in infinite; bottom: 2.1rem; transform-origin: bottom; } @keyframes ballBouncing { 0%, 100% { transform: scale(1.5, 0.5); } 20% { t.........完整代码请登录后点击上方下载按钮下载查看
网友评论0