原理虽然简单,可JavaScript和CSS可真够折磨人啊!
实现效果:
1、图片轮动,实时显示倒影;
2、鼠标移入静止放大图片,倒影也放大;
3、鼠标移出继续图片轮动。
下面是代码:
<html>
<head>
<title>带倒影的动画效果模拟</title>
<style type="text/css">
body {text-align:center;
topmargin:0;
leftmargin:0;
background:yellow;}
text-align:center;
topmargin:0;
leftmargin:0;
red;
width:1024;
height:600;
border:0;
overflow:hidden;
z-index:1;}
top:20;
left:0;
width:1024;
height:300;
blue;
overflow:hidden;
}
top:320;
left:0;
width:1024;
height:300;
background:green;
overflow:hidden;
}
img {width:100%;
height:100%;
}
margin-left:9px;
marginr-ight:9px;
float:left;
width:60px;
height:40px;
top:260px;
}
margin-left:9px;
marginr-ight:9px;
float:left;
width:400px;
height:300px;
top:0px;
}
margin-left:9px;
marginr-ight:9px;
float:left;
width:60px;
height:40px;
top:0px;
filter:alpha(opacity=30) flipv();
}
.BottomSetMid {position:relative;
margin-left:9px;
marginr-ight:9px;
float:left;
width:400px;
height:300px;
top:0px;
filter:alpha(opacity=30) flipv();
}
</head>
<div ID=dawn0919>
<div ID=dawn0718>
<span class=TopSetOther ID=TopBlock1 ID=PicTop1 src="pic/1.jpg"/></span>
<span class=TopSetOther ID=TopBlock2 ID=PicTop2 src="pic/2.jpg"/></span>
<span class=TopSetOther ID=TopBlock3 ID=PicTop3 src="pic/3.jpg"/></span>
<span class=TopSetOther ID=TopBlock4 ID=PicTop4 src="pic/4.jpg"/></span>
<span class=TopSetMid ID=TopBlock5 ID=PicTop5 src="pic/5.jpg"/></span>
<span class=TopSetOther ID=TopBlock6 ID=PicTop6 src="pic/6.jpg"/></span>
<span class=TopSetOther ID=TopBlock7 ID=PicTop7 src="pic/7.jpg"/></span>
<span class=TopSetOther ID=TopBlock8 ID=PicTop8 src="pic/8.jpg"/></span>
<span class=TopSetOther ID=TopBlock9 ID=PicTop9 src="pic/9.jpg"/></span>
</div>
<span class=BottomSetOther ID=BottomBlock1><img ID=PicBottom1 src="pic/1.jpg"/></span>
<span class=BottomSetOther ID=BottomBlock2><img ID=PicBottom2 src="pic/2.jpg"/></span>
<span class=BottomSetOther ID=BottomBlock3><img ID=PicBottom3 src="pic/3.jpg"/></span>
<span class=BottomSetOther ID=BottomBlock4><img ID=PicBottom4 src="pic/4.jpg"/></span>
<span class=BottomSetMid ID=BottomBlock5><img ID=PicBottom5 src="pic/5.jpg"/></span>
<span class=BottomSetOther ID=BottomBlock6><img ID=PicBottom6 src="pic/6.jpg"/></span>
<span class=BottomSetOther ID=BottomBlock7><img ID=PicBottom7 src="pic/7.jpg"/></span>
<span class=BottomSetOther ID=BottomBlock8><img ID=PicBottom8 src="pic/8.jpg"/></span>
<span class=BottomSetOther ID=BottomBlock9><img ID=PicBottom9 src="pic/9.jpg"/></span>
</div>
</body>
<script language=javascript type=text/javascript>
var ICurrentSpanID;
var IMainSpanID;
ICurrentSpanID=6;
IMainSpanID=5;
}
StopSwith();
ICurrentSpanID=ISPanID;
SwitchID();
}
function SwitchID(){
if (ICurrentSpanID!=IMainSpanID) {
document.all["TopBlock"+ICurrentSpanID].style.width = 400;
document.all["TopBlock"+ICurrentSpanID].style.height = 300;
document.all["TopBlock"+ICurrentSpanID].style.pixelTop = 0;
document.all["BottomBlock"+ICurrentSpanID].style.height = 300;
document.all["BottomBlock"+ICurrentSpanID].style.pixelTop = 0;
}
else
{
document.all["TopBlock"+ICurrentSpanID].style.pixelLeft = document.all["TopBlock"+ICurrentSpanID].style.offsetLeft - 400;
document.all["BottomBlock"+ICurrentSpanID].style.pixelLeft = document.all["BottomBlock"+ICurrentSpanID].style.offsetLeft - 400;
}
document.all["TopBlock"+IMainSpanID].style.height = 40;
document.all["TopBlock"+IMainSpanID].style.pixelTop = 260;
document.all["BottomBlock"+IMainSpanID].style.height = 40;
document.all["BottomBlock"+IMainSpanID].style.pixelTop = 260;
document.all["BottomBlock"+i].style.pixelTop = 0;
}
IMainSpanID=ICurrentSpanID;
ICurrentSpanID=ICurrentSpanID+1;
if (ICurrentSpanID>9){ICurrentSpanID=1;}
}
}
window.clearInterval(TimerID);
}
Init();
TimerStart();
}
</html>
