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

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 39 of 44 pages « First  <  37 38 39 40 41 >  Last »

I tweeked the code to do exactly what I wanted. I got it to fix itself in the screen so that none of the popup image would be off screen and found out how to position it in the screen. Now when I have multiple thumbnails on sceen, I can see all the popouts without having to scroll up or down. Just took some experimentation. I also set the height of the image so it would not exceed the screen.

I placed notes by each attribute I manipulated in the css:
<style type='text/css'>

/* Popout Image Viewer
----------------------------------------------- */
/*Credits: Dynamic Drive CSS Library */
/*URL: http://www.dynamicdrive.com/style/ */

.thumbnail{
position: relative;
z-index: 0;
}

.thumbnail:hover{
background-color: transparent;
z-index: 50;
}

.thumbnail span{ /*CSS for enlarged image*/
position: fixed; /* set fixed to keep from moving while scrolling */
background-color: #666699;
padding: 2px;
border: 1px solid gray;
visibility: hidden;
color: black;
text-decoration: none;
}

.thumbnail span img{ /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
height: 525px; /* specified to prevent popout from being cut off screen */
}

.thumbnail:hover span{ /*CSS for enlarged image on hover*/
visibility: visible;
top: 25px; /* position where popout will display related to top of browser window */
left: 400px; /* pos where enlarged image should offset horizontally */
}
</style>
Posted by Stoutie on 07/23, 06:44 PM
Thanks for a great example. Use it on my site.

/Per, Giftoverload.com
Posted by Per on 07/27, 02:09 AM
I have been messing with these photo zoom codes on myspace. A nice little challenge since they do weird stuff with their code...IE the # sign cant be used. I have hit a wall, It will roll over, except its not the image that is rolling over. The rest of the page does a rollover. Anyone have any ideas how to get passed this?
Posted by bob on 07/27, 10:30 AM
if there is a "select" ,it is error!!
please try it:

<a class="thumbnail" href="#thumb">media/dynamicdrive.gif<span>media/zoka.gif
Simply beautiful.</span></a>
<select><option>湖南<//option><option>北京<//option></select>
<a class="thumbnail" href="#thumb">media/ocean_thumb.jpg<span>media/ocean.jpg
So real, it's unreal. Or is it?</span></a>
Posted by xqxujun on 07/27, 08:51 PM
I am having an issue when the images pops up. When a link that is towards the right half of paragraph id hovered over, a portion of the right side of the image is cut off.

The paragraph is on a page that is within an iframe that is within a div tag.

I could change

.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*/
visibility: visible;
top: 0;
left: -400px; /*position where enlarged image should offset horizontally */

But, If any future links are on the left of a paragraph, they will get cut off on the left.

I need help fixing this to make the popup stay inside the iframe.
Posted by Richard Anderson on 07/28, 08:58 AM
NM....

I found a solution....

I made a 2nd style named thumbnailr.

Make one offset 60 and the other -400.. I can just use the style needed depending if the text is left or right
Posted by Richard Anderson on 07/28, 09:06 AM
Hey thanks for the code, just one quick tip I recently discovered using your wonderful code. in the CSS section ".thumbnail span" add the attribute "display:none" because if you try using this in a form there is a weird box that interferes with the tab index of the fields, and adding this eliminates this problem. Thanks again for tha code.
Posted by reptile on 07/28, 09:55 PM
I forgot to mention that in the ".thumbnail:hover span" you also need to add "display:block" for the popups to continue working. :)
Posted by reptile on 07/28, 10:00 PM
I'm having a problem with this, when using large popups, how to keep the popup within the boundaries of the user's browser window. Right now, if hovering over an image to the far right of the screen, the popup will simply load off the screen and force the user to scroll over to see it. Ideally I would like it to recognize when it breaks the boundaries of the window.
The User need to scroll the see the image.
I need to put the image in one prescribed position of the screen so that the user need not to scroll the screen to see the image.
Any solution for these?
Posted by Bhushan Pawar on 07/30, 01:23 AM
Apart from Above issue, I am also facing another issue.
On MOuseOVer when the image Pop's Up, the quality of the image is very poor. Does anyone have any solution for this
Posted by Bhushan Pawar on 07/31, 01:49 AM

Comment Pages 39 of 44 pages « First  <  37 38 39 40 41 >  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