Jump to content
  • Advertisement
Sign in to follow this  
Slaru

[web] More trouble with CSS and new site

This topic is 4976 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 {
	color:#000070;;
	font-size:11px;
	text-decoration:underline;
	font-weight:550;
	font-family:verdana, arial, helvetica, sans-serif;
	}
a img { /* Gets rid of border around images. */
	border:none;
	}
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
Advertisement
Don't set the a:hover globally. Do something like this, instead:

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

That way it will only affect A tags inside the #menu element.

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
Does anyone know how to set the background color for all images that are links to transparent, and the background of all other links to another color?

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!