首页 技术 正文
技术 2022年11月20日
0 收藏 550 点赞 2,811 浏览 1698 个字
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>利用jquery制作滚动到指定位置触发动画</title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
<style type="text/css"> * {
margin: 0px;
padding: 0px;
} .gs {
position: relative;
top: 100px;
font-weight:bold;">#099;
left: 150px;
width: 80px;
} .xz {
animation: roate 2s;
animation-fill-mode: forwards;
animation-direction: alternate;
} .gs {
float: left;
} @keyframes roate {
from {
transform: rotate(0deg);
width: 100px;
height: 100px;
}
to {
transform: rotate(360deg);
width: 200px;
height: 200px;
}
} .xs {
width: 50px;
float: left;
height: 30px;
font-weight:bold;">#F90;
position: fixed;
left: 700px;
top: 0px;
}
</style>
</head><body>
<script type="text/javascript">
/*var a,b,c;
a=$("#dh").offset().top;//元素相对于窗口的距离
b=$(window).scrollTop(); //监控窗口已滚动的距离;
c=$(document).height();//整个文档的高度
d=$(window).height();//浏览器窗口的高度
element 标签
cssname 动画
offset 相对于窗口的距离
*/
function scrollnumber(element, cssname, offset) {
var a, b, c, d;
d = $(element).offset().top;
a = eval(d + offset);
b = $(window).scrollTop();
c = $(window).height();
if (b + c > a) {
$((element)).addClass((cssname));
}
} function scrollfun() {
scrollnumber("#dh1", 'xz', 100);
scrollnumber("#dh2", 'xz', 100);
scrollnumber("#dh3", 'xz', 100);
scrollnumber("#dh4", 'xz', 100);
} $(document).ready(function (e) {
scrollfun();
$(window).scroll(function () {
scrollfun();
});
});
</script>
<div style="height: 1000px;width: 100%"></div>
<div style="height: 1000px;width: 100%">
<div style="height:auto; font-weight:bold;">#999; width:auto; margin: 0 auto;">
<div class="com" style="height: auto;font-weight:bold;">darkgray;position: relative;">
<div id="dh1" class="gs">触发动画111</div>
<div id="dh2" class="gs">触发动画222</div>
<div id="dh3" class="gs">触发动画333</div>
<div id="dh4" class="gs">触发动画444</div>
</div> </div>
</div>
</body>
</html>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,996
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,510
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,353
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,137
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848