wow官网:https://www.delac.io/wow/
animate官网:https://animate.style/
一、引用
cdn引用
<head>
<link href="https://cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/wow/1.1.2/wow.min.js"></script>
</head>
或本地引用
<script src="js/wow.min.js" type="text/javascript" charset="utf-8"></script>
<link href="css/animate.css" rel="stylesheet">
记得加上这个css
.wow {
visibility: hidden;
}
初始化
<script>new WOW().init();</script>
二、 html
.wow{
background-color: rebeccapurple;
width: 100%;
height: 50px;
margin: 1000px 0;
}
<div class="wow fadeInUp" data-wow-duration="2s" data-wow-delay="0.5s"></div>
三、相关属性:
wow.js的data-wow-duration(动画持续时间)
data-wow-delay(动画延迟时间)
data-wow-offset(距离开始动画(浏览器底部))
data-wow-interation(动画重复的次数)
<section class="wow slideInLeft" data-wow-duration="2s" data-wow-delay="5s"></section>
<section class="wow slideInRight" data-wow-offset="10" data-wow-iteration="10"></section>
四、自定义设置:
在初始化wow的时候的自定义设置属性:
wow = new WOW(
{
boxClass: 'wow', // 动画的class 默认值是wow;
animateClass: 'animated', // 为animate.css触发css动画的库;
offset: 0, // 当元素与浏览器窗口有多少交叉的时候动画会出现,数值越大越难出现默认值是0,即有任何交叉就会出现;
mobile: true, // 如果设为false则在手机端不显示动画效果 默认为true;
live: true // 默认为true 持续检查页面中是否有用于wow动画样式的元素 如果设为false那么在页面加载之后再用js添加的wow样式将不会有动画效果 默认值为true;
}
) wow.init();