Results 1 to 2 of 2

Thread: CSS Image gallery onclick help needed

  1. #1
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default CSS Image gallery onclick help needed

    Hi, based on the css image gallery code and HTML (please see below) how would modify the behaviour to make the images show onClick with the mouse rather than hover??? Any advice would be greatly appreciated. Thank you, Claudia

    .gallerycontainer{
    position: relative;
    /*Add a height attribute and set to largest image's height to prevent overlaying*/
    }

    .thumbnail img{
    border: 1px solid white;
    margin: 0 5px 5px 0;
    }

    .thumbnail:hover{
    background-color: transparent;
    }

    .thumbnail:hover img{
    border: 1px solid blue;
    }

    .thumbnail span{ /*CSS for enlarged image*/
    position: absolute;
    background-color: lightyellow;
    padding: 5px;
    left: -1000px;
    border: 1px dashed gray;
    visibility: hidden;
    color: black;
    text-decoration: none;
    }

    .thumbnail span img{ /*CSS for enlarged image*/
    border-width: 0;
    padding: 2px;
    }

    .thumbnail:hover span{ /*CSS for enlarged image*/
    visibility: visible;
    top: 0;
    left: 230px; /*position where enlarged image should offset horizontally */
    z-index: 50;
    }

    ------------------------------------------------------------------------

    <div class="gallerycontainer">

    <a class="thumbnail" href="#thumb"><img src="media/tree_thumb.jpg" width="100px" height="66px" border="0" /><span><img src="media/tree.jpg" /><br />Simply beautiful.</span></a>

    <a class="thumbnail" href="#thumb"><img src="media/ocean_thumb.jpg" width="100px" height="66px" border="0" /><span><img src="media/ocean.jpg" /><br />So real, it's unreal. Or is it?</span></a>

    <br />

    <a class="thumbnail" href="#thumb"><img src="media/sushi2_thumb.jpg" width="100px" height="75px" border="0" /><span><img src="media/sushi2.jpg" /><br />Sushi for dinner anyone?</span></a>

    <a class="thumbnail" href="#thumb"><img src="media/horses_thumb.jpg" width="100px" height="70px" border="0" /><span><img src="media/horses.jpg" /><br />Run wild with horses.</span></a>

    <br />

    <a class="thumbnail" href="#thumb">Dynamic Drive<span><img src="media/dynamicdrive.gif" /><br />Dynamic Drive</span></a>

    <br />

    <a class="thumbnail" href="#thumb">Zoka Coffee<span><img src="media/zoka.gif" /><br />Zoka Coffee</span></a>

    </div>

  2. #2
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    Try doing this with the thumbnail:hover:

    CSS:
    Code:
    .thumbnail span { /* Hover was here and taken away */
    background-color: transparent;
    behavior: url(thumb.htc);
    }
    HTC:
    thum.htc
    Code:
    <attach for="element" event="onclick" handler="enlarge" />
    
    <script type="text/javascript">
    function enlarge(void)
    {
    /* whatever you want to happen after the image is clicked */
    }
    </script>
    Note that this only works for Internet Explorer.

    -magicyte

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
  •