Jump to content

Using rollover background image as link


khizerk

Recommended Posts

Hi,

I'm trying to achieve this:

There are three links (no link text, its written on the image itself). I want these three buttons to appear side by side horizontally. Each button will have an hover and active background image. I'm using rollover technique to achieve this.

 

Here's my CSS:

s#overall a{
  display:inline;
  width: 26px;
  height: 26px;
}

s#overall a:hover{
  background-position: -26px 0;
}
s#overall a:active{
  background-position: -52px 0;
}

s#report-icon  {
   background: url('images/icon_post_report.png') 0 0 no-repeat; 
}

s#info-icon  a{
   background: url('images/icon_post_info.png') 0 0 no-repeat; 
}

 

Here's my HTML:



 

The problem is that if I use inline, the images (and the links) don't appear. If I use block, they appear but vertically (due to the line break). The only thing that seemed to be working was inline-block which isn't being supported by IE.

 

Is there any solution?

 

Thank you

Link to comment
Share on other sites

I made an example here:-

 

http://www.wickham43.com/forumposts/khi090412.html

 

which uses your code (slightly adapted) has three-part images for the link, hover and active states.

 

Edit: the above link works using the s attribute but doesn't validate, so this is the same using divs which does validate:-

 

http://www.wickham43.com/forumposts/khi090412-2.html

 

Remember that people with bad eyesight using a screen reader won't have any link text to read, so I believe that you can add a title to the links so that a screen reader will read something and let a blind person know where to click.

Edited by Wickham
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...