Hey there, fellow store owners! It's your friendly Shopify expert, and today we're diving into a super common, yet incredibly frustrating, design headache that many of you face: those pesky gaps between images and text blocks on mobile. You know the ones – they make your beautifully designed sections look a little disjointed when viewed on a phone. Well, good news! The Shopify community has some fantastic insights on how to tackle this, and I'm here to break it all down for you.
The Mobile Spacing Dilemma: Why It Happens
Recently, a store owner named JustinasR posted in the community, asking for help with an "image vs text gap." They were trying to reduce the space between a text card and an image in their mobile view, specifically for sections that looked like featured collection items or image-with-text blocks. The standard theme settings just weren't cutting it.
Take a look at what JustinasR was dealing with (the red marks highlight the unwanted gap):
This is a super common issue. Most Shopify themes are designed to be responsive, meaning they adapt to different screen sizes. However, sometimes the default padding and margins that look great on desktop can create awkward spacing when elements stack on top of each other on mobile. This often requires a little custom CSS to fine-tune.
Community Solutions: Two Great Approaches
Thankfully, the community quickly jumped in with some excellent, actionable solutions. Both Moeed and Steve_TopNewYork offered CSS snippets that can help you achieve that seamless look.
Moeed's Approach: Targeting Collection Featured Items
Moeed's solution is straightforward and great for targeting specific sections often used for showcasing collections or featured products. Here's how he suggested implementing it:
Go to your Shopify Admin.
Navigate to Online Store > Themes.
Find your current theme, click Actions > Edit Code.
In the file editor, find the theme.liquid file.
Add the following code at the very bottom of the file, right above the
tag:
Why this works: This CSS targets elements within a .collection-featured-item section. The @media screen and (max-width: 767px) ensures these changes only apply to screens 767 pixels wide or smaller (typical mobile devices). By setting padding-bottom: 0 !important; on the info block and margin-top: 0 !important; on the image, you effectively remove any default spacing that might be pushing them apart. The !important tag overrides any conflicting styles.
Here's a visual of the kind of result you can expect:
Steve_TopNewYork offered a slightly different, yet equally effective, solution that might be more suitable if your theme uses slightly different class names for these sections, often referred to as "image-with-text" blocks. He suggested adding the CSS to your theme’s base.css or theme.css file (you can usually find these in the Assets folder under Edit Code).
Key Differences: Notice the class names here are .image-with-text__content and .image-with-text__media, which are common in many modern Shopify themes. Also, the media query breakpoint is slightly different at 749px. This is a subtle but important distinction, as different themes might have different breakpoints where their mobile layouts kick in.
If that first snippet doesn't quite do the trick, Steve had a follow-up suggestion to target the grid layout itself:
This second piece of code is fantastic because it directly targets the gap and row-gap properties of a grid container. Many Shopify sections are built using CSS Grid, and explicitly setting these to 0 !important; can be a very robust way to eliminate spacing between stacked elements.
Which Solution Should You Use?
So, you've got two great options! How do you choose?
The best approach is to first inspect your specific page elements. You can do this by right-clicking on the image or text block in question on your live site (in a desktop browser) and selecting "Inspect" (or "Inspect Element"). Look at the class names associated with the image container and the text container. If you see classes like .collection-featured-item, Moeed's solution is probably your best bet. If you see .image-with-text__content or .image-with-text__media, then Steve's suggestions are likely what you need.
You might even find that a combination, or a slightly tweaked version, of these works best for your unique theme. Always remember to test your changes on an actual mobile device or use your browser's developer tools to simulate different screen sizes.
A Few Pro Tips for Customizing Your Shopify Store:
Backup Your Theme: Before making any code changes, always, always duplicate your theme. This way, if something goes wrong, you can easily revert to a working version.
Be Specific: When adding CSS, try to be as specific as possible with your selectors to avoid unintended changes elsewhere on your site. The solutions above are great examples of specific targeting.
Test, Test, Test: After implementing any CSS, check your store on various mobile devices (iOS, Android, different browsers) to ensure everything looks perfect.
Learn Basic CSS: Even a little knowledge of CSS can go a long way in making minor tweaks and customizations to your Shopify store. It empowers you to take control of your design.
Tackling these small design frustrations can make a huge difference in how professional and polished your Shopify store looks and feels to your customers. It's all about providing a smooth, engaging experience, no matter how they're browsing. Don't be afraid to dive into the code a little – the community is always there to help, and with these tips, you're well on your way to a perfectly spaced mobile layout!
Share:
Use cases
Explore use cases
Agencies, store owners, enterprise — find the migration path that fits.