Results 1 to 2 of 2

Thread: css-image-gallery div:active error

  1. #1
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default css-image-gallery div:active error

    Hi,

    I'm trying to modify the css-image-gallery code found here:
    http://www.dynamicdrive.com/style/cs...-gallery/P400/

    I've removed the :hover in the css and substituted it for :active, (see code below) in the attempt to have the image show on mouse click.

    It seems to work ok in FF 3.6.12, but in IE 8 it doesn't do anything on click.

    CSS (sits inside global <style type="text/css">...</style> and head tags:
    Code:
    /*Credits: Dynamic Drive CSS Library */
    /*URL: http://www.dynamicdrive.com/style/ */
    
    .gallerycontainer{
    	position: relative;
    /*Add a height attribute and set to largest image's height to prevent overlaying*/
    }
    
    .thumbnail img{
    	border: 1px solid white;
    	margin: 3px 3px 3px 3px;
    }
    
    .thumbnail:active{
    	background-color: transparent;
    }
    
    .thumbnail:active img{
    	border: 1px solid blue;
    }
    
    .thumbnail span{ /*CSS for enlarged image*/
        visibility: hidden;
        position: absolute;
        top: 20%;
        left: 25%;
        background-color: lightyellow;
        padding: 5px;
        border: 1px dashed gray;
        color: black;
        text-decoration: none;
        z-index: 50;
    }
    
    .thumbnail span img{ /*CSS for enlarged image*/
        border-width: 0;
        padding: 2px;
    }
    
    .thumbnail:active span{ /*CSS for enlarged image*/
        visibility: visible;
        position: fixed;
        top: 20%;
        left: 25%;
        background-color: lightyellow;
        padding: 5px;
        border: 1px dashed gray;
        color: black;
        text-decoration: none;
        z-index: 50;
    }
    Note. I have kept the HTML portion of the code consistent with the original provided:

    Code:
    <div class="gallerycontainer" align="center">
      <a class="thumbnail" href="#thumb">
    <img src="images/gallery/photo-0.jpg" width="150px" height="100px" border="0" />
    <span><img src="images/gallery/photo-0.jpg" /><br />Sunset.</span>
     </a>
      
      <a class="thumbnail" href="#thumb">
      <img src="images/gallery/photo-1.jpg" width="150px" height="100px" border="0" />
    <span><img src="images/gallery/photo-1.jpg" /><br />Running horses.</span>
     </a>
      
      <a class="thumbnail" href="#thumb">
    <img src="images/gallery/photo-2.jpg" width="150px" height="100px" border="0" />
    <span><img src="images/gallery/photo-2.jpg" /><br />Hill top.</span>
     </a>
    </div>
    Any help on what I'm doing wrong would be greatly appreciated. Or an alternative way to create the on click effect I'm after would also be great.

    Thanks.

  2. #2
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    On .thumbnail:active span instead of position: fixed try position: absolute.
    I tried this on IE9 so idk if its gonna be the same for IE8 try it out and let me know.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •