Ai
1 Star 0 Fork 0

唐能发/Example

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
animate.html 1.87 KB
一键复制 编辑 原始数据 按行查看 历史
唐能发 提交于 2016-10-08 09:02 +08:00 . 上传
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>animate</title>
<style type="text/css">
body{
width: 100%;
font-size: 14px;
background:#fff;
margin: 0px;
padding: 0px;
overflow: auto;
}
.container{
position: relative;
height: 1200px;
width: 1024px;
margin: 0px auto;
overflow: auto;
}
.left_ball,.right_ball{
position: absolute;
top:0px;
width:128px;
height:128px;
line-height: 128px;
text-align: center;
border-radius: 128px;
color: #fff;
}
.container .left_ball{
left:0px;
background: skyblue;
}
.container .right_ball{
right:0px;
background: pink;
}
</style>
</head>
<body>
<div class="container">
<div class="left_ball">左球</div>
<div class="right_ball">右球</div>
</div>
</body>
<script type="text/javascript" src="semantic/js/jquery.min.js"></script>
<script type="text/javascript">
function left(){
if($(this).scrollTop() <= 128 && $(this).scrollTop() > 64){
$(".left_ball").animate({left:'448px',top:'640px'},'fast',function(){
$(this).stop().fadeOut(500);
if($(window).scrollTop() <= 64 && $(window).scrollTop() >= 0){
$(this).fadeIn(500).animate({left:'0px',top:'0px', opacity: '1',display:'block'},
'slow',function(){
$(this).stop(false,true);
$(this).css("display","block");
left();
});
}
});
}
}
function right(){
if($(this).scrollTop() <= 128 && $(this).scrollTop() > 64){
$(".right_ball").animate({right:'448px',top:'640px'},'fast',function(){
$(this).stop().fadeOut(500);
if($(window).scrollTop() <= 64 && $(window).scrollTop() >= 0){
$(this).fadeIn(500).animate({right:'0px',top:'0px',opacity: '1',display:'block'}
,'slow',function(){
$(this).stop(false,true);
$(this).css("display","block");
right();
});
}
});
}
}
$(window).scroll(function(){
left();
right();
});
</script>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/TNF/Example.git
git@gitee.com:TNF/Example.git
TNF
Example
Example
master

搜索帮助