move over image

Associate
Joined
18 Aug 2004
Posts
1,886
Location
midlands
hi,

could someone tell me how to make it so when i mouse over a image it switches to a bigger version of it?

or have it so the site loads the image then displays a smaller version of it then shows its full size on mouse over

hope i explained that right and not confusing :)

thanks
nickels
 
While we are on the subject, any one cracked an image rollover that starts life out as a list. AND that works in Safari?
 
SherberT* said:
While we are on the subject, any one cracked an image rollover that starts life out as a list. AND that works in Safari?
you want text that when you hover displays an image?
 
CSS code >> is fine as long as you dont want it enlarging too much as i cant seem to get it to load a 2nd picture on rollover :(

html side
Code:
<div id="imageholder"><img src="[COLOR=Red]IMAGE LINK HERE[/COLOR]"></div>

CSS side
Code:
body { background: #464646; }

img { display: block; } /*to fix the gap with IE and Firefox*/

#imageholder img:hover {width: 1440px;
height: 900px;}

#imageholder {width: 133px;
height: 83px;
background-color: #858E85;}

obviously heights and widths will vary

complete html one >> works with all sizes ;)
Code:
<body onLoad="MM_preloadImages('[COLOR=Red]ENLARGER ROLLOVER HERE[/COLOR]')">

<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','[COLOR=Red]ENLARGER ROLLOVER HERE[/COLOR]',1)"><img src="[COLOR=Red]NORMAL IMAGE HERE[/COLOR]" name="Image1" border="0"></a>

</body>
 
Last edited:
dont seem to be able to get either of them to work... just loads the small image, doesnt get bigger on mouse over
 
soz took so long to reply, been at college all day and then had coursework to do at home :o

and now my computer seems to have a flu and so is mis behaving :mad:

Edit: now its work and i have to say my bad >>>

complete html one
Code:
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
Code:
<body onLoad="MM_preloadImages('[COLOR=Red]ENLAGED IMAGE[/COLOR]')">
<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('[COLOR=Red]ENLARGED IMAGE[/COLOR]',1)"><img src="[COLOR=Red]NORMAL IMAGE[/COLOR]" name="Image1" border="0"></a>
</body>

obviously put the script with the rest of the script in the html doc then the actual image in the body ;)

sorry bout missing 1st bit :(
 
Last edited:
would it not just be easier to use the hover element in the CSS?
something like this should do:

HTML
Code:
<img class="hoverimg" src="IMAGE LOCATION">

CSS
Code:
img.hoverimg:hover {
  height:DESIRED HEIGHTpx;
  width:DESIRED WIDTHpx
}

the desired width and height are the size of the enlarged image
 
EirePlane said:
would it not just be easier to use the hover element in the CSS?
something like this should do:

HTML
Code:
<img class="hoverimg" src="IMAGE LOCATION">

CSS
Code:
img.hoverimg:hover {
  height:DESIRED HEIGHTpx;
  width:DESIRED WIDTHpx
}

the desired width and height are the size of the enlarged image

probably but im only just starting to get into css so i dont know much sorry :( only built 4 little mess around sites where as you prob have done a lot more and know a lot more about it :(
 
Back
Top Bottom