Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2005
    Location
    San Jose, CA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preventing image links to have a background color?

    I'm a little new to CSS so I apologise if this is an easy answer. I want all hyperlinks to change the background color when the cursor hovers over it. But I don't want image links to change though. What code prevents this? Thanks!

    Code:
    a:hover {
    color:2E415A;
    font-size:10pt;
    font-family:arial;
    font-style:normal;
    text-decoration:none;
    background-color:DDEEFF;
    	}

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hmm. I'm not sure you can. Right now there's no way to style an element based on its children.

  • #3
    cfc
    cfc is offline
    Regular Coder
    Join Date
    Dec 2004
    Location
    Keswick, Ontario
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you'll have to give your image links a class of their own...

    a.imglink:hover {
    background-color: transparent | any colour;
    }

    if you're talking about borders, use:

    a img {
    border: none;
    }

    <a class="imglink" href="somewhere"><img src="myimage.png"/></a>

  • #4
    New Coder
    Join Date
    Jan 2005
    Location
    San Jose, CA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks cfc, that worked. You're the man!!


  •  

    Posting Permissions

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