Shopify themes, liquid, logos, and UX
Hi,
I am using Prestige theme and I am trying to add a custom badge "Ready to Ship" based on a variant metafield. I am able to do that by adding code in product-card.liquid and css in theme.css. However, when I hover over the product image and the product image changes to 2nd one; the tag becomes white. I am not able to figure out how ensure this does not happen. Sharing a recording of the behaviour right now (cannot share the website link, the client is not ok with that at this stage): https://www.awesomescreenshot.com/video/34605457?key=7685355cb9d7be007c6835da85c9ade6
This is the CSS I am using:
.main-rts {
display: flex;
justify-content: space-between;
text-align: center;
align-items: center;
flex-wrap: wrap;
position: absolute;
width: 310px;
}
.main-rts img {
width: 25px;
margin-bottom: 3px;
}
.variant__description {
width: 39px;
margin-right: 5px;
}
.SizeSwatchList.HorizontalList.HorizontalList--spacingTight {
margin-top: 30px;
}
.rts {
position: absolute;
top: 7px;
right: -7px;
}
And this is the code:
{%- if tag contains 'Ready To Ship' -%}
<span class="rts"><img src="https://cdn.shopify.com/s/files/1/1993/9477/files/New_Project_27_50x.png?v=1649828527"></span>
{%- break -%}
{%- endif -%}
Appreciate any help.
Thanks,
Priyanka
Solved! Go to the solution
This is an accepted solution.
It seems that the badge is inheriting some styles or behavior when the product image changes. This likely happens because the hover state modifies the product image container or overlays elements in a way that affects the badge.
Here's how you can resolve this issue:
Ensure the Badge Stays on Top
Add a z-index to the .rts class to ensure it remains visible above all other elements.
Add Background or Reset Inherited Styles
If the badge appears white due to inheritance or background issues, explicitly set its background or color:
Prevent Badge from Being Affected by Hover State
Modify the hover state to ensure the badge remains unaffected. For instance, if .product-card or equivalent is the hover target, make sure .rts isn't styled indirectly:
Ensure that the badge is applied outside of the element that changes on hover (like the image container). You can place it directly inside the product card but outside the image wrapper.
For example:
This ensures the .rts span isn't directly influenced by the hover effects on the .product-image-wrapper.
Let me know if the issue persists or if you need further guidance!
This is an accepted solution.
It seems that the badge is inheriting some styles or behavior when the product image changes. This likely happens because the hover state modifies the product image container or overlays elements in a way that affects the badge.
Here's how you can resolve this issue:
Ensure the Badge Stays on Top
Add a z-index to the .rts class to ensure it remains visible above all other elements.
Add Background or Reset Inherited Styles
If the badge appears white due to inheritance or background issues, explicitly set its background or color:
Prevent Badge from Being Affected by Hover State
Modify the hover state to ensure the badge remains unaffected. For instance, if .product-card or equivalent is the hover target, make sure .rts isn't styled indirectly:
Ensure that the badge is applied outside of the element that changes on hover (like the image container). You can place it directly inside the product card but outside the image wrapper.
For example:
This ensures the .rts span isn't directly influenced by the hover effects on the .product-image-wrapper.
Let me know if the issue persists or if you need further guidance!
Thanks @rifat_Shop . Adding the z-index solved the issue. Thanks for the detailed explanation 🙂
Best regards,
Priyanka
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024