This is because you're using a background-image on the <li>
element, as opposed to the <img>
element itself. Because this is a parent element of the image, the background will never be shown above the image itself.
If you would like to keep the background image on the parent element, you could simply add a rule of opacity:0;
for the child <img>
element on hover.
e.g.
.product.type-product:hover img {
opacity:0;
}
This will set the image opacity to 0 when you hover over the parent <li>
element.
Another option you have is to add a container to the <img>
element, and use a :before
selector on that container element with the secondary image as the background image.
This would look something like:
ul.products li.product img {
position:relative;
}
ul.products li.product .product-image-container:before {
content:"";
display:none;
background: url(https://proteinandpantry.com/wp-content/uploads/2018/09/BeefJerkySaltAndPepper-324x324.jpg) no-repeat;
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:1;
}
And then show the before on hover of the parent:
.product.type-product:hover .product-image-container:before {
display:block;
}
See an example of this here:http://jsfiddle.net/g5u4Lbxn/
Most browsers don't support the :before
selector on images, so you'll need to add a container element for the image
With the image container element, the HTML for that particular <li>
element should look like this:
<li class="post-1394 product type-product status-publish has-post-thumbnail product_cat-protein first instock shipping-taxable purchasable product-type-simple">
<h2 class="woocommerce-loop-product__title">Spicy Teriyaki Turkey Jerky</h2>
<div class="product-image-container">
<img width="324" height="324" src="https://proteinandpantry.com/wp-content/uploads/2018/09/TurkeyJerky-324x324.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail wp-post-image">
</div>
<div class="star-rating">
<span style="width:100%">Rated <strong class="rating">5.00</strong> out of 5</span>
</div>
<span class="price">
<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>2.50</span>
</span>
<a href="/shopnew/?add-to-cart=1394" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="1394" data-product_sku="" aria-label="Add “Spicy Teriyaki Turkey Jerky” to your basket" rel="nofollow">Add To Box</a>
<a class="xoo-qv-button" qv-id="1394"><span class="xoo-qv-btn-icon xooqv-search xoo-qv"></span>Learn More</a>
</li>