How to make product image change when mouse over in Shopify

Hura Product Showcase Builder

You can add a hover effect to your product images on the home page and on collection pages. When a customer moves the cursor over a product image, the image will change to show either an alternate product image:

Follow the steps for the customization:

Step 1: Add CSS to your stylesheet

To add a hover effect, you will need to add some CSS code to your theme’s stylesheet:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, and then click Actions > Edit code.
  3. In the Assets directory, click theme.css.liquid. If your theme doesn’t have a theme.css.liquid file, then click styles.css.liquid, or another file with a .css.liquid file extension.
  4. At the very bottom of the file, paste this code hosted on GitHub.
  5. Click Save.

Step 2: Edit the code for your product images

To edit the code for your product images:

  1. In the Snippets directory, click product-grid-item.liquid.If your theme doesn’t have a product-grid-item.liquid file, then look for one of the following:
    • product-card.liquid
    • product-card-grid.liquid
    • product-loop.liquid
  2. Find the HTML img tag for your product images by searching for:

    The code for the tag varies theme to theme, but always starts with <img, and ends with either > or />. It might look similar to this:

  3. On a new line above the img tag, paste the following code:

    On a new line below the img tag, paste the following code:

    The result should look like this:

  4. On a new line below the img tag and above the closing </div> tag, add the code that changes what is shown on hover. The code that you add will vary depending on whether you want to show an alternate product image, custom text, or a combination of the two.

Step 3: Show an alternate product image on hover

  1. On a new line below the img tag and above the closing </div> tag, paste the following code:

    Your code should look like this:

  2. Click Save.

DEMO

Hura Theme Blocks

You may also like...

13 Responses

  1. jitendra says:

    Hi
    can you give tutorials on cart drawer in shopify?

  2. Jeremy Zeran says:

    Hi, does this work with the Brooklyn theme? I have tried it multiple times with no luck

  3. ummeruman says:

    doesnt work in debut theme

  4. Tania says:

    I can’t get this to work in the DEBUT theme either ;(

  5. Robert Andrews says:

    Doesn’t work in Debut as of today for me.
    Tried the same code method from elsewhere. Text just hovers over the image.

  6. Kate Clark says:

    This doesn’t work for the Envy them.

  7. Haley says:

    Thank you very much. Worked perfectly!

Leave a Reply

Your email address will not be published. Required fields are marked *