Sign in to follow this  

[web] More trouble with CSS and new site

Recommended Posts

Hello, On the site I am working on, someone already helped me fix a problem where I had a border around an image. (The answer seemed so simple, and I felt stupid.) The problem now is that I have the background color of a link set to white when the mouse hovers over it. I don't want this affect with images though. How can I get rid of it? The CSS in question:
a {
	font-family:verdana, arial, helvetica, sans-serif;
a img { /* Gets rid of border around images. */
a:link {color:#000070;}
a:visited {color:#000045;}
a:hover {background-color:#fff;}
/* Here is the line I thought would work: */
a img:hover {background-color:transparent;}

Thanks, Slaru

Share this post

Link to post
Share on other sites
I tried

#menu a:hover {background:#fff;}

and it worked. However, I would like to make it so that all images have a transparent background when hovered over with one statement, instead of a #menu a:hover... for every element. Is this possible?

Share this post

Link to post
Share on other sites

a:hover {background-color: red;}
a.classname {background-color: transparent;}


<a href="thing.html">link one</a>
<a href="thing.html">link two</a>
<a class="classname" href="thing.html"><img src="happy.gif"></a>
<a class="classname" href="thing.html"><img src="sad.gif"></a>

There are no ancestor or parent selectors in CSS so you will have to distinguish the links containing images manually.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this