Wednesday, February 15, 2006

Image Effect Javascript

I think the image effect in "Union day" post must be interesting for some people. My friend, Mayvelous, asked about that and she also has a post about “LightBox JS” on her blog. So, I think it would be helpful if I post about the script I used here too.

The use of this effect is that you wanna put big image on ur page but it would mess up your layout or it would load big image against user’s will. So, what do we do? We put small thumbnail and link it to high-resolution image. Not quite cool. You gotta click the thumbnail. Look the image. Hit the back button. Wait for page loading again. No good!!!! That’s not rock n’ roll.

Ok… whatever… no more blah blah blah.

Here is the demo with Mandy Moore image. ;-)

Here is the script.

img.small_to_large {

img.small_to_largelarge {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    display: none;
    border: 1px solid #3366cc;

div.small_to_large {
    position: relative;
    overflow: visible;

HTML (place the following where you wanna see your image.)
<div class="small_to_large">
<a href="javascript:return(void)" onmouseover="'block';">
<img src="" alt="Mandy Moore" name="img_img" class="small_to_large" />

<a href="javascript:return(void)" onmouseout="'none';">
<img src="" alt="Mandy Moore" name="large_img_mandy" class="small_to_largelarge" />

Replace the yellow text accordingly.
Here… is thumbnail image
mandywall6vv.jpg is big image
large_img_mandy is element name.

Technorati Tags:


  1. Wow bro,
    This one is really short and simple CSS+JS effect. Pretty handy in some places. It's fast loading too. Cool.
    Thanks for the code bro. :)

  2. Cool effect for images :-)


Note: Only a member of this blog may post a comment.