Inserting curves into a:hover?

Associate
Joined
12 Aug 2004
Posts
1,009
Location
Glasgow, Scotland
Hi there,

This isn't to important, but i'm wondering if anyone knows of a way to insert 2 images onto either side of a link when a user hovers over it.

So for example, you would have normal a:link properties, such as background: #fff; ... but then when a user hovered over the link a:hover would have a new background colour and then 2 curves (images) so it would look like the link was inside a circular enclosure.

I thought of just putting in a background image but each link would change in size so there would be no way in knowing the size required for the image. Ideally setting the left and right border with images is what i'm after, but that won't work as css doesn't allow it.

Thanks,

Steven.
 
can't you just use a bg image and then if the link is bigger, just add a width to the image to make it the right size? or if the link is small then just make it smaller again with the width?
 
The links will be read in from a database that will be managed externally, so i'm not to sure that would be the best idea...

Hmm, i might have to give the idea a miss, i thought at first the background image would stretch automatically, but then remembered it will only repeat itself, although ... if i were to create an image that was really long wouldn't it compress into the correct size for a small link?
 
It's difficult to do with pure css alone, at least until CSS3 which will have border-images, but that's lightyears off any kind of widespread browser support (we still don't have full CSS2 support in most browsers!).

It can be done with javascript, but you have to decide if it's worth the hassle. Otherwise you could just use 2 seperate images for the full link, one for default state and one for hover.
 
MagSafe said:
The links will be read in from a database that will be managed externally, so i'm not to sure that would be the best idea...

Hmm, i might have to give the idea a miss, i thought at first the background image would stretch automatically, but then remembered it will only repeat itself, although ... if i were to create an image that was really long wouldn't it compress into the correct size for a small link?


Nope, it would crop the background around the width of the element.
 
Lovemonk said:
By careful use of the right background image, couldn't you use Sliding Doors for this?

Alistapart Sliding Doors

For sliding doors, you need a wrapping element. If you only want the image to appear on mouse hover, you'd need an element which supports the :hover. Usually, li:hover is used, which works in FF/Opera, but not IE6. Don't know about IE7 - they say they've fixed it....

If you're not worried about IE6 support, then sliding doors is ideal.
 
Works nicely if you can have them all the same width.

Use li. Set width and padding on either side. li:hover has a background image. Easy. Just thinking about a variable width solution though...
 
Back
Top Bottom