Results 1 to 2 of 2

Thread: Highlight Image in CSS

  1. #1
    Join Date
    Mar 2010
    Location
    Canada
    Posts
    32
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Highlight Image in CSS

    I have this:
    Code:
    img.decor{
    	text-decoration:none;
    	border:#CCCCCC thin solid;
    	padding: 4px;
    }
    My HTML:
    HTML Code:
    <a href="google.com"><img class="decor" src="images/birds.jpg" /></a>


    when I hover over the image "decor" in my CSS, I would like the whole image to turn grey. I tried this:
    Code:
    img.decor a:hover{background-color:#CCCCCC;}
    but it doesn't work. Any ideas??
    I just start learning CSS. thanks

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there locbtran,

    here is one possible solution for you to try...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    
    <title>turn image grey on hover</title>
    
    <style type="text/css">
    #decor{
        display:block;
        width:357px;
        height:211px;
        text-decoration:none;
        background-color:#ccc;
     }
    #decor img{
        display:block;
        width:347px;
        height:201px;
        padding:4px;
        border:1px solid #ccc;
        background-color:#fff;
     }
    #decor:hover img {
        opacity:0;
        filter:alpha(opacity=0);
     }
    </style>
    
    </head>
    <body>
    
    <div>
     <a id="decor" href="http://www.google.com"><img src="http://www.coothead.co.uk/images/girl.jpg" alt=""></a>
    </div>
    
    </body>
    </html>
    
    coothead

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
  •