-
獲取元素的left值,在元素沒有邊框的情況下用offsetLeft比較好,因為獲取的值為數(shù)字,可以直接加減,如果用obj.style.left的話獲取的結(jié)果為字符串,還要用parseInt()轉(zhuǎn)換成整數(shù)。查看全部
-
JS動畫效果: 運動框架實現(xiàn)思路: 1.速度(改變值left,right,width,height,opacity) 2.緩沖運動 3.多物體運動 4.任意值變化 5.鏈?zhǔn)竭\動 6.同時運動查看全部
-
多物體東西運動,所有東西都不能公用。查看全部
-
多物體運動,需要分別清除定時器查看全部
-
每一個元素都加一個timer,分別指定清除查看全部
-
透明度 變化 改變透明度查看全部
-
透明度查看全部
-
Math.floor向下取整 即3.4變3 Math.ceil想上取整 即3.4變4查看全部
-
JS動畫效果: 2-1:速度動畫: 為防止動畫累加,在每次觸發(fā)動畫事件時,應(yīng)該先清除前一個沒有完成的動畫,即清除錢一池開啟的定時器,然后這次再開啟一個定時器。 offsetLeft值可以獲取當(dāng)前的left值, 而offsetLeft屬性不能被賦值,只能獲取查看全部
-
6種運動方式!查看全部
-
filter:alpha(opacity:30); opacity:0.3查看全部
-
style.style.filter style.style.opacity查看全部
-
josn查看全部
-
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標(biāo)題文檔</title> <style> body,div{ margin:0; padding:0; } #div1{ width:200px; height:200px; background:red; filter:alpha(opacity:30); opacity:0.3; } </style> <script> window.onload = function(){ var oDiv =document.getElementById('div1'); oDiv.onmouseover=function(){ startMove(100); } oDiv.onmouseout=function(){ startMove(30); } } var timer = null; var alpha = 30; function startMove(iTarget){ var oDiv =document.getElementById('div1'); clearInterval(timer); timer=setInterval(function(){ var speed = 0; if(alpha>iTarget){ speed = -10; } else{ speed = 10; } if(alpha == iTarget){ clearInterval(timer) } else{ alpha+=speed; oDiv.style.opacity = alpha/100 } },30) } </script> </head> <body> <div id="div1"></div> </body> </html>查看全部
-
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>速度動畫</title> <style> body,div,span{ margin:0; padding:0; } #div1{ width:200px; height:200px; background:#F00; position:relative; left:-200px; } #share{ width:20px; height:50px; background:blue; position:absolute; left:200px; top:75px; } </style> <script> window.onload = function(){ var oDiv =document.getElementById('div1'); oDiv.onmouseover=function(){ startMove(10,0); } oDiv.onmouseout=function(){ startMove(-10,-200); } } var timer=null; function startMove(speed,iTarget){ clearInterval(timer); var oDiv=document.getElementById('div1'); timer=setInterval(function(){ if(oDiv.offsetLeft == iTarget){ clearInterval(timer); } else{ oDiv.style.left= oDiv.offsetLeft+speed+'px'; } },30) } </script> </head> <body> <div id="div1"><span id="share">分享</span></div> </body> </html>查看全部
舉報
0/150
提交
取消