Forums

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

Home Forums CSS Help changing images on :hover

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #145195
    SamuelNeudeck22
    Participant

    I need to take a series of images and place them inline across the page and from there make them change to a different image on hover.
    there is also supposed to be a link when the image is clicked.
    how do you suggest writing my html/css to do this?

    #145198
    Paulie_D
    Member

    There are a lot of ways to do this.

    The simplest would be to give each link an ID, add a background image and then just swap out the image when that ID is hovered.

    Alternatively, you could add the image inside the link, absolutely position the secondary image and re-position both images on hover.

    Without knowing the specific application you intend this for it’s hard to offer the best advice.

    Is this a menu, a gallery, is SEO important, what about accessibily?

    #145256
    SamuelNeudeck22
    Participant

    Paulie,

    The application is just for a runner above the footer that highlights brands sold at the company I’m designing for. as customers rollover the images of their favorite brands the image switches from a grayscale photo to a color photo.

    I tried your first example and nothing shows up. my paths for the images are correct:

    HTML:

    <div id=”brand-runner”>








    </div>

    CSS:

    #145263
    SamuelNeudeck22
    Participant

    the images are in a runner above the footer and highlight major brands sold at this company. when the customer rolls over the image of their favorite brand it turns from a grayscale photo to a color photo.
    I tried your first suggestion and assuming image paths are correct. it did not show up on the page. do I have to give height & width to the background images?

    #145269
    Paulie_D
    Member

    Not necessarily but the anchor should be display:block and should have the necessary dimensions to show both images.

    Without seeing some code it’s hard to comment further.

    Could you make a reduced case in Codepen?

    You can use dummy images from lorempixel.com if necessary.

    #145280
    SamuelNeudeck22
    Participant

    Okay I created a pen with the dummy images. If I’m doing things right when you rollover the grey image a color image should present itself. it looks like there might be some layering issues?

    http://codepen.io/SamuelNeudeck22/showcase

    #145281
    SamuelNeudeck22
    Participant

    I just updated it

    #145282
    SamuelNeudeck22
    Participant

    Probem solved Paulie. Tanks for the help.

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