Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Arbitrary value Motion frame of js

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report