How to reduce these spaces?

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-info elements with margin-top: 0 and margin-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.

Summarized with AI on November 4. AI used: claude-sonnet-4-5-20250929.

1 Like

@Reyan , could you kindly share yuour store url?

https://catpillar.co.uk/products/catpillar-doodle-mat-ocean-adventure-edition

Hi @Reyan

Try this one.

  1. From your Shopify admin dashboard, click on “Online Store” and then “Themes”.
  2. Find the theme that you want to edit and click on “Actions” and then “Edit code”.
  3. 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;
}

Your Feedback Matters! Please mark the solution and give likes to posts that helped you. Your appreciation fuels our motivation to assist you better!

I applied this but why i am not getting results like yours

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!