首页 / 育儿 / 正文

css3animation(Github上流行的CSS3动画效果库,你有没有尝试过——animate.css)

放大字体  缩小字体 来源:陨落星辰作者 2026-04-17 17:38  浏览次数:8

介绍

animate.css v4正在进行许多改进和重大更改,包括CSS自定义属性支持(又称CSS变量)和类前缀,以确保安全使用。感兴趣的小伙伴可以上github关注进展以及提供反馈!

Github

https://daneden.github.io/animate.css/


Github上流行的CSS3动画效果库,你有没有尝试过——animate.cssnerror="javascript:errorimg.call(this);">


安装使用

  • 使用npm安装
$ npm install animate.css --save

要在你网站中使用animate.css,只需将样式表放入文档的<head>中,然后将动画类(animated)与任何动画名称一起添加到元素中,那么一个简单的动画效果就实现了,一下就是一个最简单的例子:

<head> <link rel="stylesheet" href="animate.min.css"></head>

<h1 class="animated infinite bounce delay-2s">Example</h1>

可以更改动画的持续时间,添加延迟或更改动画播放的次数:

.yourElement { animation-duration: 3s; animation-delay: 2s; animation-iteration-count: infinite;}

Github上流行的CSS3动画效果库,你有没有尝试过——animate.cssnerror="javascript:errorimg.call(this);">


  • Javascript的用法:

还可以检测动画何时结束:

const element = document.querySelector('.my-element')element.classList.add('animated', 'bounceOutLeft')element.addEventListener('animationend', function() { doSomething() })

并像这样使用它:

animateCSS('.my-element', 'bounce')// oranimateCSS('.my-element', 'bounce', function() { // Do something after animation})

可以直接在元素的class属性上添加延迟,如下所示:

<div class="animated bounce delay-2s">Example</div>
Github上流行的CSS3动画效果库,你有没有尝试过——animate.cssnerror="javascript:errorimg.call(this);">


  • 快慢class

Animate.css由gulp.js提供支持,这意味着你可以轻松创建自定义版本。

总结

有些时候你看到别人的网站,感觉速度也不是很快,但是很自然,那么很有可能是使用了动画,使用动画不会加快网站的访问速度,但是可以让网页浏览器来更加的平滑、更加的自然,使用起来会感觉很舒适,不会给人卡顿的感觉!

打赏
0相关评论
热门搜索排行
精彩图片
友情链接
声明:本站信息均由用户注册后自行发布,本站不承担任何法律责任。如有侵权请告知立立即做删除处理。
违法不良信息举报邮箱:115904045
头条快讯网 版权所有
中国互联网举报中心