Christian Heilmann

Linking both text and icons with rollover state

Thursday, March 2nd, 2006 at 10:55 pm

Common issues Following a comment I put on the amazing redesign of Veerle’s Blog, she answered that she needed to use two links – one for a text and one for an icon to make the icon clickable.

It can be done in one link in various ways (embedding an image for example) ,but the coolest seems to be to use a background image in CSS, and add enough padding to show it as a background. This also allows you to easily create a rollover state with CSS and an appropriate picture.

Check the example page

The code:


articles RSS

And the CSS trick:

p.rss a:link,
p.rss a:visited{
padding-right:28px;
line-height:17px;
font-size:.85em;
text-decoration:none;
color:#9b9c93;
height:25px;
float:left;
background:url(rssani.gif) top right no-repeat transparent ;
}

p.rss a:hover,
p.rss a:focus,
p.rss a:active{
background-position:100% -91px;
}

Share on Twitter