Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS css image hover

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36400
    dynamyc
    Member

    I have this markup:





    and this css markup for the hover :

    #contestbuttons img#bt1:hover {background:url('../images/buton1hover.png')no-repeat; width:261px;height:39px;}

    And it’s not working, same for the 2nd image.
    What is wrong?

    #95705
    Tcooper
    Member

    You are trying to add a background to an img element, that isn’t going to work. I’m guessing you want something like:


    .button1 {
    background: url('/images/buton1.png') no-repeat;
    height: 39px;
    width: 261px;
    text-indent: -9999px;
    }

    .button1:hover {
    background-image: url('/images/buton1hover.png');
    }

    You should also look into how sprites work to save you an extra HTTP request on this sort of thing – https://css-tricks.com/css-sprites/

    Also, image replacement if you haven’t come across the text-indent stuff before – https://css-tricks.com/css-image-replacement/

    #95713
    afferennen
    Member

    Agreed. CSS sprites will definitely help you in this, because it won’t be making two HTTP requests for two images, only one.

    Check out SpriteRight on the Mac App Store as well. It might help if you’re new at this.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.