console
function scale(){
startMove(this, JSON.parse('{"left":0,"top":0,"width":"100%","height":"100%","z-index":100}'));
}
function reset(left,top){
this.style.left = left;
this.style.top = top;
this.style.width = "50%";
this.style.height = "50%";
this.style.zIndex = 0;
}
function getStyle(obj, name) {
if (obj.currentStyle) {
return obj.currentStyle[name];
} else {
return getComputedStyle(obj, null)[name];
}
}
function startMove(obj, json, fnEnd,n)
{
var MAX=18;
clearInterval(obj.timer);
obj.timer=setInterval(function (){
var bStop=true;
for(var name in json)
{
var iTarget=json[name];
if(name=='opacity')
{
var cur=Math.round(parseFloat(getStyle(obj, name))*100);
}
else
{
var cur=parseInt(getStyle(obj, name));
}
var speed=(iTarget-cur)/5;
speed=speed>0?Math.ceil(speed):Math.floor(speed);
if(Math.abs(speed)>MAX)
speed=speed>0?MAX:-MAX;
if(name=='opacity')
{
obj.style.filter='alpha(opacity:'+(cur+speed)+')';
obj.style.opacity=(cur+speed)/100;
}
else
{
obj.style[name]=cur+speed+'px';
}
if(cur!=iTarget)
{
bStop=false;
}
}
if(bStop)
{
clearInterval(obj.timer);
if(fnEnd)
{
if(typeof n === 'undefined')
{
fnEnd();
}
else
{
fnEnd(n);
}
}
}
}, 70);
}
<div style="width:300px;height:150px;position:relative;">
<div onmouseout="reset.call(this,0,0)" onmouseover="scale.call(this)" class="child" style="position:absolute;left:0;top:0;background-color:#ff0000;width:100%;height:50%;"></div>
<div onmouseout="reset.call(this,'50%',0)" onmouseover="scale.call(this)" class="child" style="position:absolute;left:50%;top:0;background-color:#ffff00;width:50%;height:50%;"></div>
<div onmouseout="reset.call(this,0,'50%')" onmouseover="scale.call(this)" class="child" style="position:absolute;left:0;top:50%;background-color:#4cad5b;width:50%;height:50%;"></div>
<div onmouseout="reset.call(this,'50%','50%')" onmouseover="scale.call(this)" class="child" style="position:absolute;left:50%;top:50%;background-color:#69359a;width:50%;height:50%;"></div>
</div>