Jump to content

Rollovers


_tina_

Recommended Posts

Hi,

 

I have a button as follow:

 

#memberlogin .login{
background:url(/images/memberlogin_btn.gif) no-repeat left top;
display:block;		
width:130px;
height:31px;
border:0; 
}

 

I need to make a rollover.  This is one image, same as this method:

http://www.nowcss.com/links/image-rollover-with-css

 

I tried it this way

#memberlogin a.login span { 
        display: none; 
}

#memberlogin a.login:hover { 
        background: url(/images/memberlogin_btn.gif) repeat 0px -31px; 
}

but it's not working, do you know what I'm doing wrong here?

 

Thanks in advance.

Link to comment
Share on other sites

It depends on what you need your buttons to do. If you need a flexible-width button, the second method was fine, but if it's fixed width, the first one was fine, though I wouldn't do it exactly the way they did. I do mine like this:

 

First, lets imagine we are using the image from the first tutorial: rss-feed-img.png

 

HTML:

<a href="#" id="target">Link</a>

CSS:

a#target
{
  height:0;
  padding-top:44px; // this is half the height of the whole image, since we only want to show the top half of the image
  width:123px; // this is the width of the image
  overflow:hidden;
  line-height:1.1em; // without this, some of the text is visible in Safari and Opera
  background:url(http://www.nowcss.com/wp-content/uploads/2007/01/rss-feed-img.png) no-repeat left top;
}

a#target:hover
{
  background-position:left -44px; // we move the background image up, so that now the bottom half the image is visible
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.