【导语】:animate.css 是一个有趣的,跨浏览器的CSS3 动画库。

简介

animate.css 是一个有趣的,跨浏览器的 css3 动画库,兼容性好,使用方便。它预设了抖动、闪烁、弹跳、翻转、旋转、淡入淡出等多达 60 多种动画效果,几乎包含了所有常见的动画效果。

animate.css 基于 CSS3,只兼容支持 CSS3 animate 属性的浏览器,IE10+、Firefox、Chrome、Opera、Safari。

项目地址是:

https://github.com/animate-css/animate.css

安装

使用 npm 安装:

$ npm install animate.css --save

使用 yarn 安装:

$ yarn add animate.css

使用 CDN 直接引入:

<head>

  <link

    rel="stylesheet"

    href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"

  />

</head>

简单使用

基本用法。安装 animate.css 后,将以下属性添加到中即可完成动画效果的创建。

<h1 class="animate__animated animate__bounce">An animated element</h1>

自定义属性。使用自定义属性来定义动画持续时间、延迟,这使得它非常灵活,当需要更改动画持续时间的时间,只需要为全局或本地设置一个新值。

/* This only changes this particular animation duration */

.animate__animated.animate__bounce {

  --animate-duration: 2s;

}

/* This changes all the animations globally */

:root {

  --animate-duration: 800ms;

  --animate-delay: 0.9s;

}

同时自定义属性还可以动态更改所有时间受限的属性,可以通过 JS 脚本动态修改。

// All animations will take twice the time to accomplish

document.documentElement.style.setProperty('--animate-duration', '2s');

// All animations will take half the time to accomplish

document.documentElement.style.setProperty('--animate-duration', '.5s');

延迟效果:可以直接在元素的 class 属性上添加延迟效果:

<div class="animate__animated animate__bounce animate__delay-2s">Example</div>

// animate.css 提供了这些延迟属性:

class               默认延迟时间

animate__delay-2s   2s

animate__delay-3s   3s

animate__delay-4s   4s

animate__delay-5s   5s

// 也可以通过 --animate-delay 属性进行自定义:

/* All delay classes will take 2x longer to start */

:root {

  --animate-delay: 2s;

}

/* All delay classes will take half the time to start */

:root {

  --animate-delay: 0.5s;

}

动画速度:可以通过添加这些 class 来控制动画的速度:

<div class="animate__animated animate__bounce animate__faster">Example</div>

// 速度的 class 包括这些:

class            默认速度

animate__slow    2s

animate__slower  3s

animate__fast    800ms

animate__faster  500ms

// 可以通过 --animate-duration 全局或本地属性自定义动画时间:

/* All animations will take twice as long to finish */

:root {

  --animate-duration: 2s;

}

/* Only this element will take half the time to finish */

.my-element {

  --animate-duration: 0.5s;

}

循环效果:可以通过添加这些 class 来控制动画的循环次数:

<div class="animate__animated animate__bounce animate__repeat-2">Example</div>

// 可供选择的 class 有:

class              循环次数

animate__repeat-1  1

animate__repeat-2  2

animate__repeat-3  3

animate__infinite  无限循环

// 类似的,也可以自定义循环次数:

/* The element will repeat the animation 2x

   It's better to set this property locally and not globally or

   you might end up with a messy situation */

.my-element {

  --animate-repeat: 2;

}

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

热门产品

触发修改文章时间【fastadmincms开发记录】|fastadmincms二次开发,触发,修改,文章,时间,fastadmin,ms,开发,记录
触发修改文章时间【fastadmincms开发记录】
在tp5中过滤输入的零宽度字符【fastadmincms开发记录】|fastadmincms二次开发,在tp5中,过滤,输入,的零,宽度,字符,fastadmin,ms,开发,记录
在tp5中过滤输入的零宽度字符【fastadmincms开发记录】
处理tag标签中的0宽空格【fastadmincms开发记录】|fastadmincms二次开发,处理,tag,标签,中的,0宽,空格,fastadmin,ms,开发,记录
处理tag标签中的0宽空格【fastadmincms开发记录】
添加专题时tags标签id出错【fastadmincms开发记录】|fastadmincms二次开发,添加,专题,时tags,标签,id,出错,fastadmin,ms,开发,记录
添加专题时tags标签id出错【fastadmincms开发记录】
20230518----模板 广告【fastadmincms开发记录】|fastadmincms二次开发,20230518,模板,广告,fastadmin,ms,开发,记录
20230518----模板 广告【fastadmincms开发记录】
cms添加视频模型【fastadmincms开发记录】|fastadmincms二次开发,ms,添加,视频,模型,fastadmin,开发,记录
cms添加视频模型【fastadmincms开发记录】
新增单篇收费复制功能【fastadmincms开发记录】|fastadmincms二次开发,新增,单篇,收费,复制,功能,fastadmin,ms,开发,记录
新增单篇收费复制功能【fastadmincms开发记录】
添加开会员折扣功能【fastadmincms开发记录】|fastadmincms二次开发,添加,开会,折扣,功能,fastadmin,ms,开发,记录
添加开会员折扣功能【fastadmincms开发记录】

历史上的今天:05月03日

热门专题

自考本科|自考本科有用吗,自考文凭,自考本科文凭,自考文凭有用吗,自考本科文凭有用吗,自考文凭承认吗
自考本科
国家开放大学|国家开放大学报名,国家开放大学报考,国家开放大学,什么是国家开放大学,国家开放大学学历,国家开放大学学费,国家开放大学报名条件,国家开放大学报名时间,国家开放大学学历,国家开放大学专业
国家开放大学
安徽中源管业有限公司|安徽中源管业有限公司,安徽中源管业有限公司介绍,安徽中源管业有限公司电话,安徽中源管业有限公司地址,安徽中源管业有限公司厂家,安徽中源管业有限公司电力管,安徽中源管业有限公司管材
安徽中源管业有限公司
天麻的功效与作用吃法|天麻的功效与作用,天麻的功效与作用吃法,天麻炖什么治头痛最好,天麻的功效与作用禁忌,天麻多少钱一斤,天麻的功效与作用吃法及禁忌,天麻怎么吃效果最好,天麻粉的功效与作用,天麻怎么吃
天麻的功效与作用吃法
卓越综合高中|卓越综合高中
卓越综合高中
小程序开发|微信小程序,小程序开发,小程序,小程序制作,微信小程序开发,小程序公司,小程序开发公司,分销,三级分销系统,分销系统
小程序开发
弥勒综合高中|弥勒综合高中
弥勒综合高中
云南巨榕教育投资集团有限公司|云南巨榕教育投资集团有限公司,巨榕教育集团,巨榕教育
云南巨榕教育投资集团有限公司

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部