My product card image ratio is set to square and I have the photos contained to that area. I have successfully made the unused area of the square white on the webpage but not on mobile. I’ve tried a couple of things but no luck. Does anyone know how to accomplish this?
Topic summary
A user encountered an issue where product card images on their Shopify store displayed gray edges on mobile devices, despite successfully making these edges white on desktop. The product cards use a square aspect ratio with contained images.
Problem Details:
- Desktop version showed white backgrounds correctly
- Mobile version displayed unwanted gray edges around product images
- User had already attempted several solutions without success
Solution Provided:
Two CSS code solutions were offered:
- First solution (successful):
@media (max-width: 749px) {
.card--standard .card__inner:after { background: #fff; }
}
- Alternative solution:
@media screen and (max-width: 1023px){
.card__inner .card__media {
background-color: #fff;
}
}
Both solutions target mobile viewports using media queries to change the background color from gray to white.
Resolution:
The issue was resolved using the first CSS solution. The user confirmed it worked successfully and did not need to test the alternative approach.
Hi @d0ug
Please share the password-protected link to your store so we can check!
Hello @d0ug
Welcome to the Shopify Community! Please share your store URL and password (if it’s password-protected), so I can check and provide you with the exact solution.
Please share me your store password so can I figure out for you the reason and solution to fix
ahljad
ahljad
Please add this code to Custom CSS in Sales channels > Online Store > Themes > Customize > Theme settings
@media (max-width: 749px) {
.card--standard .card__inner:after { background: #fff; }
}
Let try to add this css code to remove gray background :
@media screen and (max-width: 1023px){
.card__inner .card__media {
background-color: #fff;
}
}
Thanks!!
I didn’t get to try your solution because the first one worked
oh Thank for let me know
Thanks!!
It seems to have worked
You are very welcome!



