有些网页在向下滚动的时候,一些元素会产生细小的动画效果,比如滚动到图片时,图片从下到上进入,从左至右等等。虽然动画幅度较小,但却能吸引你的注意。比如刚刚发布的 iPhone 6 的页面。如果你希望你的页面也更加有趣,那么你可以试试 WOW.js。
WOW.js 依赖 animate.css,所以它支持 animate.css 多达 60 多种的动画效果,能满足您的各种需求。
animate.css地址:http://daneden.github.io/animate.css/
如果想单独 添加动画效果,不指定动画的延时及播放时间等,直接调用css样式即可
XML/HTML代码
- <div class="animated bounceOutLeft"></div>
如果想要延时等等功能,则需要
WOW.js 地址:http://mynameismatthieu.com/WOW/index.html
使用方法
1、引入文件
1 |
<link rel="stylesheet" href="css/animate.min.css"> |
2、HTML
1 2 |
<div class="wow slideInLeft"></div> <div class="wow slideInRight"></div> |
可以加入 data-wow-duration(动画持续时间)和 data-wow-delay(动画延迟时间)属性,如:
data-wow-duration: 改变动画持续时间
data-wow-delay: 动画开始前的延迟
data-wow-offset: 启动动画的距离(到浏览器底部的距离)
data-wow-iteration:动画重复次数
1 2 |
<div class="wow slideInLeft" data-wow-duration="2s" data-wow-delay="5s"></div> <div class="wow slideInRight" data-wow-offset="10" data-wow-iteration="10"></div> |
3、Javascript
1 |
new WOW().init(); |
如果需要自定义配置,可如下使用:
1 2 3 4 5 6 7 8 |
var wow = new WOW({ boxClass: 'wow', animateClass: 'animated', offset: 0, mobile: true, live: true }); wow.init(); |
配置
属性/方法 | 类型 | 默认值 | 说明 |
---|---|---|---|
boxClass | 字符串 | ‘wow’ | 需要执行动画的元素的 class |
animateClass | 字符串 | ‘animated’ | animation.css 动画的 class |
offset | 整数 | 0 | 距离可视区域多少开始执行动画 |
mobile | 布尔值 | true | 是否在移动设备上执行动画 |
live | 布尔值 | true | 异步加载的内容是否有效 |
未经允许不得转载:Windy's Blog » 让页面的载入更有趣,wow.js及animate.css