animate.css动画参考手册
一、animate.css 简介
Animate.css 是一个非常流行的 CSS 动画库,这个库包含了一系列预定义的 CSS 类,你可以将它们应用到 HTML 元素上,以快速实现各种动画效果。
二、animate.css 使用方法
使用 Animate.css 的方法非常简单。首先,你需要将 Animate.css 文件引入到你的项目中。
使用 npm 安装:
npm install animate.css --save
import 'animate.css';
或者,直接引入 animate.css 库文件:
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
/>
然后,你可以将预定义的 CSS 类应用到 HTML 元素上。例如:
<div class="animate__animated animate__infinite animate__bounce">我在跳动!</div>
在这个例子中,animate__animated
类表示元素应具有动画效果,而 animate__bounce
类表示元素应执行“弹跳”动画。
为了让大家看得更清楚,本文的所有动画实例都是以循环播放的效果进行展示,实际项目中如若不需要循环效果,去除“animate__infinite”类即可。
三、animate.css 可用的动画效果
Animate.css 提供了许多预定义的动画效果,包括但不限于:
- 1、
animate__bounce
:元素弹跳。
- 2、
animate__fadeIn
:元素淡入。
- 3、
animate__slideInDown
:元素从下方滑入。
- 4、
animate__pulse
:元素脉动。
- 5、
animate__swing
:元素摇摆。
- 6、
animate__wobble
:元素摇晃。
- 7、
animate__jello
:元素像果冻一样抖动。
- 8、
animate__rotateIn
:元素旋转进入。
- 9、
animate__rollIn
:元素滚入。
- 10、
animate__flash
:元素闪烁。
- 11、
animate__bounceIn
:元素弹跳进入。
- 12、
animate__flipInX
:元素在 X 轴上翻转进入。
- 13、
animate__flipInY
:元素在 Y 轴上翻转进入。
- 14、
animate__zoomIn
:元素放大进入。
- 15、
animate__fadeInUp
:元素从下方淡入。
- 16、
animate__fadeInDown
:元素从上方淡入。
- 17、
animate__fadeInLeft
:元素从右侧淡入。
- 18、
animate__fadeInRight
:元素从左侧淡入。
- 19、
animate__slideInUp
:元素从下方滑入。
- 20、
animate__slideInDown
:元素从上方滑入。
- 21、
animate__slideInLeft
:元素从右侧滑入。
- 22、
animate__slideInRight
:元素从左侧滑入。
- 23、
animate__heartBeat
:心跳。
- 24、
animate__rubberBand
:橡皮筋。
- 25、
animate__headShake
:摇头。
- 26、
animate__tada
:泰达。
- 27、
animate__backInDown
。
- 28、
animate__backInLeft
。
- 29、
animate__backInRight
。
- 30、
animate__backInUp
。
- 31、
animate__backOutDown
。
- 32、
animate__backOutLeft
。
- 33、
animate__backOutRight
。
- 34、
animate__backOutUp
。
- 35、
animate__bounceInDown
。
- 36、
animate__bounceInLeft
。
- 37、
animate__bounceInRight
。
- 38、
animate__bounceInUp
。
- 39、
animate__bounceOut
。
- 40、
animate__bounceOutDown
。
- 41、
animate__bounceOutLeft
。
- 42、
animate__bounceOutRight
。
- 43、
animate__bounceOutUp
。
- 44、
animate__fadeInDownBig
。
- 45、
animate__fadeInLeftBig
。
- 46、
animate__fadeInRightBig
。
- 47、
animate__fadeInUpBig
。
- 48、
animate__fadeInTopLeft
。
- 49、
animate__fadeInTopRight
。
- 50、
animate__fadeInBottomLeft
。
- 51、
animate__fadeInBottomRight
。
- 52、
animate__fadeOut
。
- 53、
animate__fadeOutDown
。
- 54、
animate__fadeOutDownBig
。
- 55、
animate__fadeOutLeft
。
- 56、
animate__fadeOutLeftBig
。
- 57、
animate__fadeOutRight
。
- 58、
animate__fadeOutRightBig
。
- 59、
animate__fadeOutUp
。
- 60、
animate__fadeOutUpBig
。
- 61、
animate__fadeOutTopLeft
。
- 62、
animate__fadeOutTopRight
。
- 63、
animate__fadeOutBottomRight
。
- 64、
animate__fadeOutBottomLeft
。
四、自定义动画
除了使用预定义的动画效果,你还可以使用 Animate.css 的 SASS 变量来自定义动画效果。例如,你可以修改 $colors
变量来自定义动画的颜色,或者修改 $timing-function
变量来自定义动画的速度曲线。
五、注意事项
1、在使用 Animate.css 时,请确保你已经正确引入了 Animate.css 文件,并且你的 HTML 文件中的类名与 Animate.css 中的类名一致。
2、由于 Animate.css 使用 CSS3 的动画特性,因此在一些较旧的浏览器上可能无法正常工作。在使用前,请确保你的目标浏览器支持 CSS3 动画特性。
本文地址:https://www.tides.cn/p_css-animate.css