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:
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click Actions > Edit code.
- 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.
- At the very bottom of the file, paste this code hosted on GitHub.
- Click Save.
Step 2: Edit the code for your product images
To edit the code for your product images:
-
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
-
Find the HTML img tag for your product images by searching for:
1
<imgThe code for the tag varies theme to theme, but always starts with <img, and ends with either > or />. It might look similar to this:
|
1
|
|
| - | - | -
On a new line above the img tag, paste the following code:
1On a new line below the img tag, paste the following code:
1The result should look like this:
|
1
2
3
|
|
| - | - | -
On a new line below the img tag and above the closing 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
-
On a new line below the img tag and above the closing tag, paste the following code:
|
1
|
|
| - | - |Your code should look like this:
|
1
2
3
4
|
|
| - | - | -
Click Save.