All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello,
How can I enable the display of the second product image on mobile when a user interacts with the product, such as by scrolling or touching? Currently, the second images are shown on hover on desktop, but there is no response when touching on mobile devices.
Theme is dawn.
I tried this, it doesn't work:
.card-wrapper:hover .media.media--hover-effect>img:first-child:not(:only-child) {
opacity: 0;
}
.card-wrapper:hover .media.media--hover-effect>img+img {
opacity: 1;
transition: transform var(--duration-long) ease;
transform: scale(1.03);
}
Example: https://lialay.com/collections/rings
Hi @Reneo
You can try adding this CSS code into the file assets/component-card.css like in this image
.card-wrapper:hover .media.media--hover-effect > img + img { opacity: 1 !important; transition: transform var(--duration-long) ease !important; transform: scale(1.03) !important; }
Hope it helps! Cheers 🙂
Hi, thanks for the response. I've already tried this and it doesn't work, unfortunately.
Try this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hover Effect Example</title>
<style>
:root {
--duration-long: 0.3s; /* Define the duration for the transition */
}
.card-wrapper:hover .media.media--hover-effect > img + img {
opacity: 1 !important;
transition: transform var(--duration-long) ease !important;
transform: scale(1.03) !important;
}
</style>
</head>
<body>
<div class="card-wrapper">
<div class="media media--hover-effect">
<img src="image1.jpg" alt="First Image">
<img src="image2.jpg" alt="Second Image">
</div>
</div>
</body>
</html>