JS学习-3.练习2
作者:互联网
屏幕进行抖动(类似于qq抖动)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#myBody{
position: absolute;
}
</style>
</head>
<body id="myBody">
屏幕抖动效果
<script>
var body=document.body;
var num=0;
setInterval(function(){
num=num+1;
if(num%4==1){
body.style.left="3px";
body.style.top="3px";
}
if(num%4==2){
body.style.left="-3px";
body.style.top="-3px";
}
if(num%4==3){
body.style.left="3px";
body.style.top="-3px";
}
if(num%4==0){
body.style.left="-3px";
body.style.top="-3px";
}
},30);
</script>
</body>
</html>
标签:body,3px,style,top,练习,JS,学习,num%,left 来源: https://blog.csdn.net/qq_37974765/article/details/121254899