Results 1 to 6 of 6

Thread: Using the opacity effect on hover with an existing script

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

    Default Using the opacity effect on hover with an existing script

    1) Script Title: CSS image galley

    2) Script URL (on DD): http://www.dynamicdrive.com/style/cs...-gallery/P110/

    3) Describe problem:
    I have amended this code to apply a slight opacity to the thumbnail when the mouse is over it, and it's LUVLY, BUT... The opacity also is applied to the larger image as well. Not what I wanted.

    If I add to the class
    .thumbnail:hover image{opacity:0.5;}

    the thumbnail is nicely affected on mouse over, but the same opacity applies to the large image.

    Can anyone suggest a method of applying the opacity to the thumbnail only?

    Thanks in adv.
    McP

  2. #2
    Join Date
    Oct 2009
    Posts
    845
    Thanks
    14
    Thanked 189 Times in 188 Posts

    Default

    If you make a new class and apply only to the image tag with the thumbnails it can be achieved.
    Forexample you could use this css:

    .thumbnaileffect:hover {opacity:0.5;}

    with this markup
    Code:
    <a class="thumbnail" href="#thumb"><img src="media/tree_thumb.jpg" width="100px" height="66px" border="0" class="thumbnaileffect" /><span><img src="media/tree.jpg" /><br />Simply beautiful.</span></a>
    scroll to see the new class

    For IE you would need to add:

    filter:alpha(opacity=50);

    to the css for it to work

  3. #3
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for this, just shutting donw now. I'll try this Thurs see what happens.
    Will let you know if I got it going or not. Thanks

  4. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style type="text/css">
    
    /*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: 0 5px 5px 0;
    }
    
    .thumbnail:hover{
    background-color: transparent;
    }
    
    .thumbnail:hover img{
    border: 1px solid blue;opacity:.5;
    }
    
    .main {
     opacity:1 !important;
    }
    
    .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;
    }
    
    </style>
    </head>
    
    <body>
    <div class="gallerycontainer">
    
    <a class="thumbnail" href="#thumb"><img src="http://www.dynamicdrive.com/cssexamples/media/tree_thumb.jpg" width="100px" height="66px" border="0" /><span><img class="main" src="http://www.dynamicdrive.com/cssexamples/media/tree.jpg" /><br />Simply beautiful.</span></a>
    
    <a class="thumbnail" href="#thumb"><img src="http://www.dynamicdrive.com/cssexamples/media/ocean_thumb.jpg" width="100px" height="66px" border="0" /><span><img class="main" src="http://www.dynamicdrive.com/cssexamples/media/ocean.jpg" /><br />So real, it's unreal. Or is it?</span></a>
    
    <br />
    
    <a class="thumbnail" href="#thumb"><img src="http://www.dynamicdrive.com/cssexamples/media/sushi2_thumb.jpg" width="100px" height="75px" border="0" /><span><img class="main" src="http://www.dynamicdrive.com/cssexamples/media/sushi2.jpg" /><br />Sushi for dinner anyone?</span></a>
    
    <a class="thumbnail" href="#thumb"><img src="http://www.dynamicdrive.com/cssexamples/media/horses_thumb.jpg" width="100px" height="70px" border="0" /><span><img class="main" src="http://www.dynamicdrive.com/cssexamples/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>
    
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  5. The Following User Says Thank You to vwphillips For This Useful Post:

    RobMcP (02-24-2011)

  6. #5
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Sorry for the delay in responding to your kind assistance.
    My HDD on my desktop went BANG, and I'm stuck with guessing Forum users ids and passwords cos my shortcuts got eaten eeek.
    Cheers

  7. #6
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I hate to look everybody's gift horse in the mouth, but can this code be made to work in IE7/8? or is that really asking too much?

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
  •