1 javascript jquery scroll scrollreveal.js
在阅读本教程并使用他们的代码后,我尝试使用 scrollReveal.js ,当我的视口在它们上时,我仍然无法让我的 div 淡入。
html
<head>
<script src="scrollreveal-master/dist/scrollreveal.min.js"></script>
</head>
<div data-sr>This is the first div</div>
<div data-sr>This is the second div</div>
<div data-sr>This is yet another div</div>
Run Code Online (Sandbox Code Playgroud)
javascript
new scrollReveal();
Run Code Online (Sandbox Code Playgroud)
当我在我的网页上查看控制台时,它说
“未捕获的 ReferenceError:scrollReveal 未定义”
尝试这样使用 scrollReveal 在滚动上添加动画
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="main">
<div data-sr> one </div>
<div data-sr> two </div>
<div data-sr> three </div>
</div>
<script src="https://unpkg.com/scrollreveal@3.3.2/dist/scrollreveal.min.js"></script>
<script>
// Changing the defaults
window.sr = ScrollReveal({ reset: true });
// Customizing a reveal set
sr.reveal('div', {opacity: 0.9,duration:3000});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
工作示例:https : //plnkr.co/edit/qC33zle0fafyAL0RjkVl?p=preview