Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

images, borders, links 1

Status
Not open for further replies.

iisman

Technical User
Mar 6, 2005
85
CA
Greetings,

I have an image, with text alongside, that both link to another page (same page) The text changes color when either the image or text is hovered. This is good. BUT, my image has a 1px border that I also want to chnge color when hovered. I can not seem to achieve this. my attemtps have cause a border to go around the whole thing, image AND text, when only should go around the image.

heres the code:

HTML:

Code:
<a class="archives" href="[URL unfurl="true"]http://somelink/file.asp">[/URL]
<img src="[URL unfurl="true"]http://somelink/file.gif"[/URL] alt="Archives" align="middle" class="archiveimg"/>To Archive Page</a>

CSS:

Code:
a.archives:link    {color: #333333; font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; font-weight: normal; text-decoration: none}
a.archives:visited {color: #333333; font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; font-weight: normal; text-decoration: none}
a.archives:active  {color: #333333; font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; font-weight: normal; text-decoration: none}
a.archives:hover   {color: #00ff00; font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; font-weight: normal; text-decoration: none}

.archiveimg 	{border: 1px solid #282484}
 
Try this (I've removed a lot of redundant code too):
Code:
a.archives:link, a.archives:visited, a.archives:active
{color: #333333; font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; font-weight: normal; text-decoration: none}

a.archives:hover   {color: #00ff00;}

.archiveimg     {border: 1px solid #282484}

[b]a.archives:hover .archiveimg {border-color: #00ff00;}[/b]
If the font family/size/weight of these links is the same as the ordinary body text, you don't need to repeat them in the a.archives rule - they'll be inherited. It's best to rely on inheritance wherever possible, partly because it keeps the file size down, and partly because it makes it easier to change things when you want to.

You can also do without the archiveimg class, assuming you want all images in an archives link to behave like that:
Code:
.archives img {border: 1px solid #282484}

a.archives:hover img {border-color: #00ff00;}

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top