Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<style type="text/css">
/*CSS for 2 demos on the page*/
.bubblewrap{
position:relative;
top:20px;
list-style-type:none;
margin:0;
padding:0;
}
.bubblewrap li{
display:inline-block;
zoom:1; /*Trigger haslayout in IE7 and less*/
*display:inline; /*For IE7 and less*/
position:relative;
width: 200px;
height:80px;
border:solid red 0px;
}
.bubblewrap li img{
position:absolute;
width: 100px; /*default width of each image.*/
height: 60px; /*default height of each image.*/
left:0;
top:0;
border:0;
}
.bubblewrap .tooltip{ /*CSS for image tooltip (alt attribute of image)*/
position:absolute;
font:bold 12px Arial;
left:0px;
width:100%;
text-align:center;
background:white;
}
.parent {
position:relative;overflow:hidden;width:1200px;height:200px;border:solid red 1px;
}
.menu {
position:relative;left:50px;top:20px;width:600px;height:100px;
}
.page {
width:600px;height:100px;background-Color:#FFFFCC;
}
</style>
<script type="text/javascript">
/*<![CDATA[*/
// Image Bubble (01-July-2012)
// by Vic Phillips - http://www.vicsjavascripts.org.uk/
function zxcImageBubble(o){
var ul=document.getElementById(o.ULID),menu=document.getElementById(o.MenuID),lis=ul.getElementsByTagName('LI'),m=o.MagBy,m=typeof(m)=='number'?m:1,ms=o.Animate,img,d,pw,ph,w,h,ary=[],clds=menu.childNodes,mary=[],z0=0,z1=0;
for (;z0<lis.length;z0++){
img=lis[z0].getElementsByTagName('IMG')[0];
d=lis[z0].getElementsByTagName('DIV')[0];
w=img.width;
h=img.height;
pw=lis[z0].offsetWidth;
ph=lis[z0].offsetHeight;
ary[z0]=[img,d,[w,h,(pw-w)/2,(ph-h)/2],[w*m,h*m,(pw-w*m)/2,(ph-h*m)/2]]
img.style.width=ary[z0][2][0]+'px';
img.style.height=ary[z0][2][1]+'px';
img.style.left=ary[z0][2][2]+'px';
img.style.top=ary[z0][2][3]+'px';
d.style.top=ary[z0][2][3]-d.offsetHeight+'px';
this.addevt(img,'mouseout','mse',z0,2);
this.addevt(img,'mouseover','mse',z0,3);
}
this.ary=ary;
for (;z1<clds.length;z1++){
if (clds[z1].nodeType==1){
this.addevt(clds[z1],'mouseover','mse2',z1,3);
this.addevt(clds[z1],'mouseout','mse2',z1,2);
clds[z1].style.position='absolute';
clds[z1].style.zIndex='2';
clds[z1].style.left='0px';
clds[z1].style.top='0px';
this.opac(clds[z1],0);
mary.push([clds[z1],0,'o'+z1,'lft'+z1,this.pos(mary.length)]);
}
}
menu.style.visibility='hidden';
this.mdes=['width','height','left','top'];
this.menu=menu;
this.mary=mary;
this.lst=null;
this.ms=typeof(ms)=='number'?ms:1000;
}
zxcImageBubble.prototype={
mse2:function(nu,ud){
if (this.ary[this.lst]){
this.mse(this.lst,ud);
}
},
mse:function(nu,ud){
var oop=this,ary=oop.ary[nu],img=ary[0],d=ary[1],mdes=oop.mdes,mary=oop.mary,lft=0,z0=0;
for (;z0<mdes.length;z0++){
clearTimeout(oop['to'+nu+z0]);
oop.animate(img,mdes[z0],parseInt(img.style[mdes[z0]]),ary[ud][z0],new Date(),oop.ms,'to'+nu+z0);
}
clearTimeout(oop['dly'+nu]);
oop.animate(d,'top',parseInt(d.style.top),ary[ud][3]-d.offsetHeight,new Date(),oop.ms,'dly'+nu);
d.style.top=ary[ud][3]-d.offsetHeight+'px'
while (img.parentNode){
lft+=img.offsetLeft;
if (img.nodeName.toUpperCase()=='DIV'){
break;
}
img=img.parentNode;
}
if (mary[nu]){
oop.animate(oop.menu,'left',oop.menu.offsetLeft,mary[nu][4],new Date(),oop.ms,mary[nu][3]);
clearTimeout(oop[mary[nu][2]]);
mary[nu][0].style.zIndex=ud;
oop.menu.style.visibility='visible';
oop.animate(mary[nu],'o',mary[nu][1],ud==2?0:100,new Date(),oop.ms,mary[nu][2]);
this.lst=nu;
}
},
pos:function(nu){
var ary=this.ary[nu],img=ary[0],lft=0;
while (img.parentNode){
lft+=img.offsetLeft;
if (img.nodeName.toUpperCase()=='DIV'){
break;
}
img=img.parentNode;
}
return lft+ary[2][0]-ary[3][0];
},
animate:function(obj,mde,f,t,srt,mS,to){
var oop=this,ms=new Date().getTime()-srt,now=(t-f)/mS*ms+f;
if (isFinite(now)){
if (mde!='o'){
obj.style[mde]=now+'px';
}
else {
obj[1]=now
this.opac(obj[0],now);
}
}
if (ms<mS){
oop[to]=setTimeout(function(){ oop.animate(obj,mde,f,t,srt,mS,to); },10);
}
else {
if (mde!='o'){
obj.style[mde]=t+'px';
}
else if (t==0){
oop.menu.style.visibility='hidden';
}
}
},
opac:function(obj,opc){
obj.style.filter='alpha(opacity='+opc+')';
obj.style.opacity=obj.style.MozOpacity=obj.style.WebkitOpacity=obj.style.KhtmlOpacity=opc/100-.001;
},
addevt:function(o,t,f,p,p1){
var oop=this;
if (o.addEventListener) o.addEventListener(t,function(e){ return oop[f](p,p1,e);}, false);
else if (o.attachEvent) o.attachEvent('on'+t,function(e){ return oop[f](p,p1,e); });
}
}
/*]]>*/
</script>
<script type="text/javascript">
/*<![CDATA[*/
function Init(){
new zxcImageBubble({
ULID:'orbs', // the unique ID name of the parent UL. (string)
MenuID:'menu', // the unique ID name of the menu parent DIV. (string)
MagBy:1.2, //(optional) the image magnification. (number, default = 1)
Animate:500 //(optional) the animation duration in milli seconds. (number, default = 1000)
});
}
if (window.addEventListener){
window.addEventListener('load',Init, false);
}
else if (window.attachEvent){
window.attachEvent('onload',Init);
}
/*]]>*/
</script>
</head>
<body>
<div class="parent" >
<ul id="orbs" class="bubblewrap">
<li>
<div class="tooltip" >Add to Stumbleupon</div>
<a href="http://dynamicdrive.com"><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="Add to Stumbleupon" /></a>
</li>
<li>
<div class="tooltip" >Add to Facebook</div>
<a href="http://dynamicdrive.com"><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" alt="Add to Facebook" /></a>
</li>
<li>
<div class="tooltip" >Add to Digg</div>
<a href="http://dynamicdrive.com"><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt7.jpg" alt="Add to Digg" /></a>
</li>
<li>
<div class="tooltip" >Add to Twitter</div>
<a href="http://dynamicdrive.com"><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt8.jpg" alt="Add to Twitter" /></a>
</li>
<li>
<div class="tooltip" >Add RSS Feed</div>
<a href="http://dynamicdrive.com"><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt9.jpg" alt="Add RSS Feed" /></a>
</li>
</ul>
<div id="menu" class="menu" >
<div class="page" >Menu 1</div>
<div class="page" >Menu 2</div>
<div class="page" >Menu 3</div>
<div class="page" >Menu 4</div>
<div class="page" >Menu 5</div>
</div>
</div>
</body>
</html>
Bookmarks