Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library
 
CSS Library
Submit an original CSS code
CSS Layouts
Web Graphics
Online Tools:

Advertise Here

CSS Library: Image CSS: Here

CSS Popup Image Viewer

Author: Dynamic Drive

Enable arbitrary links or image thumbnails to pop up an enlarged (different) image onMouseover by using this CSS code. With the help of CSS's ":hover" pseudo class, combined with relative and absolute positioning, the enlarged images are simply included on the page as normal HTML, "popping" up on demand. CSS is behaving more and more like scripting!

Demo:

One of my favorite foods is sushi
Doesn't this look good?
, and it's good for you too! Coffee and sushi probably don't mix well, but I like some Zoka Coffee
Zoka Coffee
to boot! Here are some thumbnails from my trip to La la land:


Simply beautiful.

So real, it's unreal. Or is it?

The CSS:

The HTML:

Code Info

Rate this code:

Date Posted: 05/07/2006

Revision History: None

Usage Terms: Click here

Your Comments (524)

Got a question or need help customizing this CSS code? Post it in the CSS Forums. If you have a comment or suggestion instead, post it in the comments section below.

Comment Pages 49 of 53 pages « First  <  47 48 49 50 51 >  Last »

hi mark
where am i supposed to put the css
is it in the head??
Posted by reut on 02/23, 07:17 AM
this code doesn't work for IE !
Posted by Boxer on 02/27, 01:43 AM
Help please,
I can't get the images to appear after I publish it.
I know the CSS and HTML are installed correct because when I preview the page in my browser it works but will not work after I publish it.

The faded boxes show up on the page in the size that I've set but, the image will not. I use Mozilla.

I tried MS Explorer and the images won't even show up on the page
Posted by Brad on 02/28, 08:16 PM
Hi
I cut & pasted the css in the HEAD and the rest in the BODY section, but i can only see the thumbnail pics no enlarged pics even when i place the mouse over them...can u help
thanks in advance
Posted by darryl on 03/01, 07:32 PM
Love this code, but as others pointed out it makes for a heavy page load, especially if you have dozens of thumbnails on a page. After some work I figured out how to remedy that.

1) Add some javascript for swapping images on mouseover. Heres a simple javascript function to place within <script> in <HEAD>.

function SwapImage(cu) {
var imgpath = "bigimage.jpg";
eval("document.images['image"+cu+"'].src=imgpath");
}

cu is a unique identifier for each image you will need to create. You can make this a sequential number of some sort. Replace imgpath with the path to the large image you will place in the container.

2) Identify the image within the container by adding a name attribute. Each popup image on the page needs to have a unique name. I accomplish this by adding a unique identifier to <img> within the <span>. I also change the src the same as the smaller thumbnail image, basically as a placeholder, example;

img src="thumbs/smallimage.jpg" name="image6"

Above shows the placeholder image within the span for the 6th thumbnail in the sequence. If you are using php / asp etc you can build this dynamically by replacing 6 with a variable.

3) Lastly I put in an onMouseover event on the small thumbnail image you will hover over.

img src="thumbs/smallimage.jpg" border="0" onmouseover="SwapImage('6');"

Again you can replace 6 with a variable if you are php/asp, etc.

Now you have a page that loads much quicker. When you first mouseover the thumbnail you will get a small image until the larger one loads.

Hope this is helpful.

Steve
Posted by steve_avs on 03/02, 11:47 AM
I used this script on a Joomla website that have suckerfish menus.

I use it for a contact list, so when you rollover the name of a person in the list, the picture of the person show's up.

The problem is that the name of the person (actual link) wich have the thumbnail class show's on top of the suckerfish submenu items on my site.

It's not a z-index issue on my site .css file. I already doublecheck it. Currently my menu is on a z-index: 6000; so this should not happen....

Any ideas how to solve this?
Posted by Peter on 03/04, 01:39 PM
Just wanted to give you a shout from the valley of the sun, great information, much appreciated. molokini
Posted by molokini on 03/09, 08:47 AM
Hey guys,

I can't seem to get the code to work correctly in I.E. Only one thumbnail shows up! I've tried looking through the comment pages and tinkering here and there with the code but I'm not sure what to do...

In Safari, the code works great and all the thumbnails show up. I'm using the code for my store on ebay so I can't use javascript and ideally I could make it work for all browsers... suggestions?
Posted by Aaron on 03/12, 06:34 PM
my site is phpbb ı did, but I do not know how to integrate
Posted by sscetin on 03/21, 05:19 AM
i'm trying to add a whole sentance underneathe the image when it pops up but it moves text into seperate lines. is there a solution to this??
Posted by Joel on 04/02, 11:02 AM

Comment Pages 49 of 53 pages « First  <  47 48 49 50 51 >  Last »

Commenting is not available in this weblog entry.
Copyright 2006-2011 Dynamic Drive Read our Usage Terms before using any of the CSS codes.