Topic summary
A user seeks to reduce excessive spacing on their Shopify product page (catpillar.co.uk). An expert provides CSS code targeting specific product info blocks (title, price, description, inventory, variant picker) to eliminate top and bottom margins.
Solution progression:
- Initial code targets desktop only using media query
@media screen and (min-width: 700px) - User reports code works on desktop but not mobile
- Expert provides updated CSS without media query restrictions to apply spacing reduction across all devices
- Code targets
.safe-sticky.product-infoelements withmargin-top: 0andmargin-bottom: 0
Implementation:
CSS added to base.css/style.css/theme.css file in theme’s Assets folder via Shopify admin.
The expert requests feedback through marking the solution and giving likes to helpful posts. Screenshots demonstrate before/after results showing reduced vertical spacing between product information sections.
@Reyan , could you kindly share yuour store url?
Hi @Reyan
Try this one.
- From your Shopify admin dashboard, click on “Online Store” and then “Themes”.
- Find the theme that you want to edit and click on “Actions” and then “Edit code”.
- In the “Assets” folder, click on “base.css, style.css or theme.css” file, depending on which file your theme uses to store its CSS styles. At the bottom of the file, add the following CSS code:
.product-info__block-item:is([data-block-type="title"], [data-block-type="price"],
[data-block-type="description"], [data-block-type="inventory"], [data-block-type="variant-picker"]) {
margin-top: 0.5rem;
}
- And Save.
- result:
Your Feedback Matters! Please mark the solution and give likes to posts that helped you. Your appreciation fuels our motivation to assist you better!
My bad. Please change your code to below
@media screen and (min-width: 700px) {
safe-sticky.product-info .product-info__block-item:is([data-block-type="title"],
safe-sticky.product-info [data-block-type="price"],
safe-sticky.product-info [data-block-type="description"],
safe-sticky.product-info [data-block-type="inventory"],
safe-sticky.product-info [data-block-type="variant-picker"]) {
margin-top: 0rem;
margin-bottom: 0rem;
}
}
Result
Great Worked on Desktop But didnt work in mobile.
Please, replace with this code.
safe-sticky.product-info .product-info__block-item:is([data-block-type="title"],
safe-sticky.product-info [data-block-type="price"],
safe-sticky.product-info [data-block-type="description"],
safe-sticky.product-info [data-block-type="inventory"],
safe-sticky.product-info [data-block-type="variant-picker"]) {
margin-top: 0rem;
margin-bottom: 0rem;
}
And Save.
Result:
Your Feedback Matters! Please mark the solution and give likes to posts that helped you. Your appreciation fuels our motivation to assist you better!





