图片抖动

<!--图片地址,请您自己更改!-->
<img src="http://www.qqbye.com/wawa/UploadFiles_3996/200807/2008071904350239_S.jpg" style="position:relative;" onMouseOver="init(this);rattleimage()" onMouseOut="stoprattle(this)" />
<script language="JavaScript">
var rector=3; // 抖动的幅度
var stopit=0;
var a=1;
 
function init(which){
stopit=0;
shake=which;
shake.style.left=0;
shake.style.top=0;
}
 
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50) // 抖动的频率
}
 
function stoprattle(which){
stopit=1;
which.style.left=0;
which.style.top=0;
}
 
</script>
 

图片和浏览器的抖动

 

<style>
	#qq{position:relative;}
</style>

<script>
	mfx = function(isWin){
		var t = 0,z = 3,del = function(){clearInterval(mfx.ID);return mfx};
		del().ID = setInterval(function(){
			var i = t/180*Math.PI,x = Math.sin(i)*z,y = Math.cos(i)*z,s = qq.style;
			isWin ? window.moveBy(x,y) : (s.top=x+'px',s.left=y+'px');
			if((t += 90) > 1080)del();
		},30);
	}
</script>

<button οnclick="mfx()">QQ</button>
<button οnclick="mfx(1)">browser</button>
<img id="qq" src="http://dl.iteye.com/upload/picture/pic/57029/fe8a74ac-add2-396d-a298-2954c162bfe7.gif"  />
 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值