954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Image links and CSS

Hey, Im trying to do a CSS rollover border color change for my images (which are links). Problem is, the border only partly covers the image, going about half way up the image on the sides, and not covering the top at all.

Id post some code, but considering the easy nature of what im trying to do i didnt think it would be necessary.

Thanks for your help,
-ryan

Woobag
Light Poster
33 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

...and

a:link img, a:visited img { border: 1px solid #000000 }
a:hover img { border: 1px solid #FF0000 }


didn't work?

FC Jamison
Posting Pro in Training
Team Colleague
446 posts since Jun 2004
Reputation Points: 92
Solved Threads: 21
 

Yes, this works. Thanks for the help.

I saw something reference the "img" part in CSS, but i couldnt apply it to work correctly in my situation.

Sweet, and since i wanted to name it, i came up with this.

#car:link img, #car:visited img { border: 1px solid #000000 }
#car:hover img { border: 1px solid #FF0000 }
Woobag
Light Poster
33 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

You might have some cross-browser compatibility issues with that solution.

FC Jamison
Posting Pro in Training
Team Colleague
446 posts since Jun 2004
Reputation Points: 92
Solved Threads: 21
 

You guessed it. In I.E. the image links are the lighter gray, and do not change colors. The image links at the top of my page (this page is included by a index.php - for example) are showing in the purple "visited" color as the would do so normally. I think i can solve the latter of those two problems, but what do you think about correcting the first?

Woobag
Light Poster
33 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

If you've named the image, try

a:link img#car, a:visited img#car { border: 1px solid #000000 }
a:hover img#car { border: 1px solid #FF0000 }
FC Jamison
Posting Pro in Training
Team Colleague
446 posts since Jun 2004
Reputation Points: 92
Solved Threads: 21
 

why dont you just make diffrent images for rollover?

Spector
Newbie Poster
2 posts since Jul 2006
Reputation Points: 11
Solved Threads: 0
 

Rollovers are more complicated, and customizing them on the fly is a bit of a pain. I am going for a style and it can be acheived both ways, and this way is the easiest.

Edit- I still get no "hover" functionality in IE6.

Woobag
Light Poster
33 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

ok...on my photo gallery page ( http://www.frankjamison.com/gallery/ ), I use a combination of css and javascript to achieve this effect.

[html] image.jpg' [/html]

.rolloverOff {
  border: 1px solid #999999;
}

.rolloverOn {
  border: 1px solid #FFFFFF;
}
FC Jamison
Posting Pro in Training
Team Colleague
446 posts since Jun 2004
Reputation Points: 92
Solved Threads: 21
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You