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 (436)

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 7 of 44 pages « First  <  5 6 7 8 9 >  Last »

wow, many thanx for that nice script
Posted by Susi on 08/10, 09:31 PM
so, i find some bugs in my script..
bugs fixed :
http://www.sevoir.hu/gallery2.zip
join it ;-)

thx a lot for css drive, for 1st script !
Posted by sevoir on 08/11, 01:19 PM
tried it on my myspace but the larger image isn't hidden. Can someone tell me how to get this code to work on myspace?
Posted by Lindsay on 08/12, 02:55 PM
Thanks for the great code! One thing I like to do is to add this: .thumbnail span {white-space: nowrap;}. Makes the text under the picture stay on one line.
Posted by Daniel on 08/14, 02:53 PM
I have multiple images that scroll all the way down the screen and when you hover over the bottom images they doesn't appear in the screen, how can I get it to display on screen?
Posted by Esteban on 08/15, 10:44 AM
This is really nice,very impressive. In html page itself it is worked easily.
Posted by deepali kardile on 08/19, 05:30 AM
Hello. I have a template that I am editing in Macromedia Flash MX. I have pictures that I have entered into the timeline. I want to add little pop up window of text on rollover that tells about the photo & goes away once you move the mouse away from text. ie My kids photos to say name, ages and birthdate. Could you tell me where I would enter this information and how exactly do i do this? I have been doing good so far on my personal site. I purchased my template from online. Thanks fo your help.
Posted by Ayana P on 08/20, 11:36 AM
I made a slight modification in the code for cross-browser compatibility to allow me to integrate this into a scrollable sidebar (I use a mod of 456 Berea Street's CSS Frames (http://www.456bereastreet.com/lab/cssframes/). Because of inconsistency in position:absolute across browsers the problem was (in Firefox) the popup was being rendered relative to the top of the physical html file rather than to the top of the viewable area resulting in the popup being further out of the frame as the page was scrolled down (in IE, it worked fine). This simple fix allowed vertical scrolling to be independent of popup position. Change the original CSS in this section:

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
visibility: visible;
top: 0;
left: 60px; /*position where enlarged image should offset horizontally */

}

to:

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
position:fixed; /* <--added for Firefox/Mozilla
visibility: visible;
top: 0;
left: 60px; /*position where enlarged image should offset horizontally */

}

and adding this in the head of the html document:

<!--[if IE]>
<style type="text/css">
.thumbnail:hover span{ /*CSS for enlarged image*/
position:absolute;
</style>
<![endif]-->

solved the problem. This has been tested in IE 5.5 and 6 on Win98 and XP and Mozilla and Firefox on Win98, XP and Mac OS X (also works in Safari). Other browsers should work as well, but I would welcome anyone with other browsers to test this and comment here. You may see my implementation of this at http://www.firstchurchofgodindependence.org

This may have been fixed in IE7, but I have an aversion to installing MS betas on my box. If anyone has IE7 installed, I would be interested in knowing if this hack causes any undesired effects. Of course the simple fix would be to replace [IF IE] with [IF<IE7] if IE7 is affected.
Posted by MrSpock on 08/24, 11:51 AM
Great Job! My only problem:

I want to have the hovered pop-up image open directly next to the link/thumb that activated it. I have not seen anyone ask about this or to offer a suggestion.

I really cannot use the offseting part of the script to get it to work.

Please help! Thanks in advance.
Posted by Ivo Dimitrov on 08/24, 12:19 PM
Response to my own response:

a possible solution I just found out is to set:

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
visibility: visible;
top: auto;
left: auto; /*position where enlarged image should offset horizontally */

So, change the 0 and 60px value to auto and auto. That will open the hovered image RIGHT next to the thumb. I still have not found a way to open it next to the thumb but, say, 10-15 pixels to the right.


ANY thoughts on this? Reply ahead... Thanks.
Posted by Ivo Dimitrov on 08/24, 12:32 PM

Comment Pages 7 of 44 pages « First  <  5 6 7 8 9 >  Last »

Name: (Required)

Email: (Required)

(NOT shown on page)

URL:

(Shown on page if entered)

Comments: (Required)

Supported BB codes: [b], [i], [u], [em], [strike], [strong], [pre], [code], and [blockquote].

Remember my personal information
Notify me of follow-up comments?

Submit the word you see below ("previewing" post does not require it):


Copyright 2006-2008 Dynamic Drive Read our Usage Terms before using any of the CSS codes.
Dynamic Drive DHTML and CSS Code Library