<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="https://cdn.bootcss.com/animate.css/3.5.2/animate.css"> <title>Document</title> <style> .container{ width: 400px; height: 400px; background-color: #ccc; margin: 100px auto; position: relative; } .container .part{ box-sizing: border-box; width: 360px; height: 120px; border-radius: 180px/60px; border: 18px solid #61dafb; position: absolute; left: 20px; top: 140px; } .container .one{ animation: rubberBand1 1s linear infinite; } @keyframes rubberBand1 { from { transform: scale3d(1, 1, 1) rotate(57deg); } 30% { transform: scale3d(1.25, 0.75, 1) rotate(57deg); } 40% { transform: scale3d(0.75, 1.25, 1) rotate(57deg); } 50% { transform: scale3d(1.15, 0.85, 1) rotate(57deg); } 65% { transform: scale3d(.95, 1.05, 1) rotate(57deg); } 75% { transform: scale3d(1.05, .95, 1) rotate(57deg); } to { transform: scale3d(1, 1, 1) rotate(57deg); } } .container .two{ animation: rubberBand2 1s linear infinite; } @keyframes rubberBand2 { from { transform: scale3d(1, 1, 1) rotate(123deg); } 30% { transform: scale3d(1.25, 0.75, 1) rotate(123deg); } 40% { transform: scale3d(0.75, 1.25, 1) rotate(123deg); } 50% { transform: scale3d(1.15, 0.85, 1) rotate(123deg); } 65% { transform: scale3d(.95, 1.05, 1) rotate(123deg); } 75% { transform: scale3d(1.05, .95, 1) rotate(123deg); } to { transform: scale3d(1, 1, 1) rotate(123deg); } } .ball{ width: 60px; height: 60px; background-color: #61dafb; border-radius: 50%; position: absolute; left: 50%; top: 50%; margin-top: -30px; margin-left: -30px; } </style> </head> <body> <div class="container"> <div class="part one"></div> <div class="part two"></div> <div class="part animated rubberBand infinite"></div> <div class="ball animated rubberBand infinite"></div> </div> </body> </html>
我发现如果你定义了transform,animate.css会把你写的效果覆盖,但是加了!important又会没动画效果,因为上面的办法就很笨,给写了transform的元素自己加动画,有不有什么好办法可以解决?然后你们有不有什么更炫酷的做法
相关分类