Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Arbitrary value Motion frame of js

Shulou Source: shulou.com Published: 2022-06-03 04:58:38 10月28日 Update

Arbitrary value Motion frame div {width:200px;height:200px;background:red;float:left;border:10px black solid;margin:50px;font-size:50px;color:yellow;} # div4 {filter:alpha (opacity:30); opacity:0.3;} _ window.onload=function () {var oDiv1=document.getElementById ('div1'); var oDiv2=document.getElementById (' div2'); var oDiv3=document.getElementById ('div3'); var oDiv4=document.getElementById (' div4') ODiv1.onmouseover=function () {StartMove (this,'width',500);}; oDiv1.onmouseout=function () {StartMove (this,'width',200);}; oDiv2.onmouseover=function () {StartMove (this,'height',500);} ODiv2.onmouseout=function () {StartMove (this,'height',100);}; oDiv3.onmouseover=function () {StartMove (this,'font-size',100);}; oDiv3.onmouseout=function () {StartMove (this,'font-size',50);} ODiv4.onmouseover=function () {StartMove (this,'opacity',100);}; oDiv4.onmouseout=function () {StartMove (this,'opacity',30);};} Function getstyle (obj,name) {if (obj.currentStyle) / / get {return obj.currentStyle [name] for ie } else / / for non-interline styles {return getComputedStyle (obj,null) [name];}}; function StartMove (obj,ss,itarget) {clearInterval (obj.timer); obj.timer=setInterval (function () {var cur=0) If (ss=='opacity') {cur=parseFloat (getstyle (obj,ss)) * 100} else {cur=parseInt (getstyle (obj,ss));} var speed= (itarget-cur) / 4 Speed=speed > 0?Math.ceil (speed): Math.floor (speed); if (itarget-cur==0) {clearInterval (obj.timer) } else {if (ss=='opacity') {obj.style.filter='alpha (opacity='+ (cur+speed) +')' / / solve the problem of deviation in obtaining transparency in ie through rounding in if-else if ((cur+speed) > = 30) {obj.style.opacity=Math.ceil ((cur+speed)) / 100 } else {obj.style.opacity=Math.floor ((cur+speed)) / 100;} document.getElementById ('txt1') .value=cur+speed } else {obj.style [ss] = cur+speed+'px';}, 30);}; wider and taller characters become larger

Tags: Frames motion deviations characters styles interline transparency questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno vpn Xiaomi Microsoft