JQ如何写一个进去页面就飘来飘去的图片
jquery吧
全部回复
仅看楼主
level 2
缪阿伦 楼主
JQ如何写一个进去页面就飘来飘去的图片,碰到浏览器的边缘就会自动弹开,随机朝着另外的方向继续飘过去
2015年11月14日 09点11分 1
level 2
缪阿伦 楼主
谁能给我一个思路?
2015年11月14日 09点11分 2
level 2
同求
2015年11月14日 12点11分 3
level 1
一般情况是判断是否到浏览器的边缘,如果到达边缘,那么朝相反的方向移动!
2015年11月19日 14点11分 4
level 9
坐标增减值反向
2015年11月22日 22点11分 5
level 1
给你个js源码的 弹力球的源码 自己改成jquery的就行.
2015年11月28日 05点11分 6
level 1
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>location</title>
<style type="text/css">
*{
padding:0px;
margin:0px;
}
#imgid{
position:absolute;
/*left:100px;
top:100px;*/
}
</style>
</head>
<body>
<img src="images/6.jpg" id="imgid">
</body>
<script type="text/javascript">
//获取img
imgid=document.getElementById("imgid");
//初始化
x=0;
y=0;
//定义速度
xv=10;
yv=10;
setInterval(function(){
//上下范围
if(y<0||y>window.innerHeight-imgid.offsetHeight){
//速度取反
yv=-yv;
}
//左右范围
if(x<0||x>window.innerWidth-imgid.offsetWidth){
//速度取反
xv=-xv;
}
x+=xv;
y+=yv;
imgid.style.left=x+"px";
imgid.style.top=y+"px";
},10);
</script>
</html>
2015年11月28日 05点11分 7
厉害!!
2015年11月30日 15点11分
无敌,大神 ,你做我师傅吧!
2016年03月18日 06点03分
@Mr▫Tian [汗]别闹,我这也是老师教的
2016年03月18日 13点03分
1