코드 복사 코드는 다음과 같습니다. 无标题文档 <br> #div1{width:100px;height:100px;background:#ccc;position:absolute;top:0px;left:0px;}<br> #div2{width:100px;height:100px;background:#ccc;position:absolute;left:0px;top:110px;}<br> #div3{width:100px;height:100px;background:red;position:absolute;left:220px;top:0px;filter:alpha(opacity:30);opacity:0.3;}<br> #div4{width:100px;height:100px;background:red;position:absolute;left:330px;top:0px;filter:alpha(opacity:30);opacity:0.3;}<br> #div5{width:100px;height:100px;background:red;position:absolute;left:440px;top:0px;filter:alpha(opacity:30);opacity:0.3;}<br><br>window.onload=function()<br>{ <br> oDiv1=document.getElementById("div1");<br> oDiv2=document.getElementById("div2");<br> oDiv3=document.getElementById("div3");<br> oDiv4=document.getElementById("div4");<br> oDiv5=document.getElementById("div5"); <p> oDiv1.onmouseover=function(){<br> Move(oDiv1,"width",200); <br> //alert(getStyle(oDiv1,"width"));<br> }<br> oDiv1.onmouseout=function(){<br> Move(oDiv1,"width",100);<br> }<br> oDiv2.onmouseover=function(){<br> Move(oDiv2,"height",200); <br> }<br> oDiv2.onmouseout=function(){<br> Move(oDiv2,"height",100);<br> }<br> oDiv3.onmouseover=function(){<br> Move(oDiv3,"opacity",100);<br> }<br> oDiv3.onmouseout=function(){<br> Move(oDiv3,"opacity",30);<br> }</p> <p> oDiv4.onmouseover=function(){<br> Move(oDiv4,"opacity",100) <br> }<br> oDiv4.onmouseout=function(){<br> Move(oDiv4,"opacity" ,30);<br> }<br> oDiv5.onmouseover=function(){<br> Move(oDiv5,"opacity",100) <br> }<br> oDiv5.onmouseout=function(){<br> Move(oDiv5,"opacity",30);<br> }<br><br> <br>} <br> //인터라인 스타일 가져오기 <br> function getStyle(obj,attr) //getStyle non- interline 속성 결과 값은 ***px입니다. <br> { if(obj.currentStyle)<br> {<br> return obj.currentStyle[attr];<br> }<br> return getCompulatedStyle(obj, false)[ attr];<br> } <br> obj.timer=setInterval(function(){<br> if(attr=="opacity")<br> { cur=parseFloat(getStyle(obj,attr))*100; <br> speed=( itarget -cur)/10;<br> speed=speed>0?Math.ceil(speed):Math.floor(speed) <br><br> if(cur==itarget)<br> {<br> clearInterval(obj.timer);<br> }else<br> > 값은 숫자로 변환됩니다. <br> speed=speed>0?Math.ceil(speed):Math.floor(speed) // 아래쪽 및 위쪽으로 양수를 취합니다. <br><br> if(cur==itarget) <br> else<br> {<br> obj.style[attr]=현재 속도 "px"; <br> } <br> } <br><br> },30) <br> } <br> <본문> 变宽 变高