Shopify Single Product Image Woes? How to Fix Awkward Layouts with CSS!

Hey there, fellow store owners! As a Shopify migration expert and someone who spends a lot of time digging through the community forums, I often come across those little quirks that can drive you absolutely batty. You know, the ones that make your perfectly curated store look… well, not so perfect.

Recently, a thread popped up that really resonated with me, and I bet it will with many of you. Our community member, Tilda_Falth, from seoulsound.se, shared a common frustration: product media looking a bit “off” on products that only have one picture.

Tilda's problem was clear: products with multiple images displayed beautifully, with the image neatly aligned at the same height as the product title. But for those single-image products, the picture was awkwardly centered within its block, creating an inconsistent and less polished look. It's a subtle detail, but these are the things that impact your store's professionalism and customer experience.

Screenshot 2026-03-25 at 21.21.15

(Above: How Tilda's multi-image products looked – perfectly aligned!)

Screenshot 2026-03-25 at 21.20.25

(Above: The “super off” look of a single-image product, vertically centered.)

Understanding the Root Cause: Aspect Ratios and Centering

The core of the problem, as expertly pointed out by tim_1 in the thread, often boils down to how your theme handles image containers. Many modern Shopify themes, for responsiveness and consistency, wrap product images in containers that enforce a specific aspect-ratio, like a perfect square. When you have multiple images, the slideshow or gallery mechanism handles this gracefully. However, with just one image, that fixed-height parent container can sometimes make your image appear vertically centered, especially if you've also applied custom CSS to limit the image's max-width or max-height (like Tilda had, with her max-width: 470px; and max-height: 470px; rules).

The Community's Solutions: A Deep Dive

It's awesome to see how the community jumped in to help! Let's break down the most promising solutions shared.

Solution 1: Unsetting the Aspect Ratio (The Most Direct Fix)

This approach, suggested by tim_1, directly addresses the fixed aspect ratio of the parent container that causes the vertical centering. By telling the browser to essentially “ignore” the enforced aspect ratio for single-media product slides, the container can then resize to fit the natural dimensions of your image, eliminating that awkward extra space.

Step-by-Step Instructions:

Here's how you can implement this simple yet powerful CSS tweak:

  1. Access Your Theme Code: From your Shopify Admin, go to Online Store > Themes.
  2. Edit Code: Find your current theme, click on Actions > Edit Code.
  3. Locate Your CSS File: Look for a file like theme.css, base.css, styles.css, or a file within the "Assets" folder that handles your main styling. Sometimes, themes have a dedicated "Custom CSS" section in the Theme Customizer, which is even better!
  4. Add the Code: Paste the following CSS snippet at the very bottom of your chosen CSS file or in your Custom CSS section. This specifically targets products with a single image:
    .slideshow--single-media slideshow-slide {
      aspect-ratio: unset !important;
    }
    
  5. Save Your Changes: Click "Save" and then check a product page with a single image on your live store.

Here's a quick visual of the “before” and “after” that tim_1 shared, showing how this code helps the image fill its space naturally:

Screenshot 2026-03-26 at 2.24.44 PMScreenshot 2026-03-26 at 2.24.57 PM

Alternative Approach: Aligning to the Top

Both tim_1 and devcoders offered solutions that focus on aligning the image to the top of its container. While this fixes the centering, it might not always give you the desired outcome if the container itself still maintains a fixed height. You could end up with a top-aligned image and empty space below it, which wasn't Tilda's goal of a seamless look.

Here are the codes they suggested:

From tim_1 (note the caveat about empty space):

.slideshow--single-media slideshow-slide {
  align-items: flex-start !important;
}

And from devcoders, targeting a slightly different selector:

.product-media-container.constrain-height:has(.product-media-constraint-wrapper) {
  display: flex;
  justify-content: center;
  align-items: flex-start !important;
}

image

While these might work in certain theme contexts, for Tilda's specific goal of having the image dictate its own height and align with the title, the aspect-ratio: unset is likely the cleaner solution.

Dealing with Image Size Constraints

Laza_Binaery brought up an interesting point about Tilda's existing code that limits image size to 470px. If you're still seeing smaller images after fixing the alignment, it might be because of similar max-width or max-height rules in your theme or custom CSS. Laza_Binaery suggested overriding these with larger values if you want your images to take up more space:

.product-media-gallery__slideshow--single-media .product-media-constraint-wrapper {
    max-width: 1200px !important;
}
.product-media-gallery__slideshow--single-media .product-media {
    max-width: 1200px !important;
    max-height: 1200px !important;
}

You can add this to your Custom CSS or main stylesheet, just like the previous snippet. Remember, the !important flag forces the style to override any other conflicting rules, but use it judiciously as it can make debugging harder later on.

Before You Implement: A Quick Word of Caution

Anytime you're diving into your theme's code, it's always a good idea to duplicate your theme first. This creates a backup, so if anything goes awry, you can easily revert to the previous version without impacting your live store. Also, keep in mind that theme updates can sometimes overwrite custom code, so it's wise to keep a personal record of your CSS modifications.

The beauty of the Shopify community is that we're all in this together, sharing solutions to make our stores look and perform better. Tilda's issue is a fantastic example of a common visual hiccup that a little bit of targeted CSS can completely resolve, making your single-image products look just as professional and appealing as your multi-image ones. Happy customizing!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases