Centering Images on Your Shopify Pages: A Community CSS Deep Dive

Getting Your Images Perfectly Centered on Shopify: A Community Approach

Hey everyone! We've been digging into the Shopify Community forums again, and this time, the hot topic was all about centering images. Specifically, user pnd195 was looking for a way to center an image on their "Meny" page (that's "Menu" in Norwegian!). It sparked some great discussion, and I wanted to share the insights we uncovered.

The original poster, pnd195, asked how to center the image on a specific page of their cafe's website. You can see the original question and the live page here. Let's dive into the solutions that the community offered.

The Code Snippet Solutions

Right off the bat, James-Bell and Moeed jumped in with CSS code snippets. James-Bell suggested adding the following code to the end of your base.css file:

.spacing-style.layout-panel-flex.layout-panel-flex--column.section-content-wrapper.mobile-column {
    justify-content: center !important;
    align-items: center !important; 
}

And Moeed suggested adding this code snippet to the bottom of the theme.liquid file, just above the tag:


Both of these solutions aim to center the image using CSS flexbox properties. The align-items: center property is key here, as it vertically centers the image within its container.

Tim_1's Perspective: Padding and Custom CSS

Now, here's where it gets interesting. Tim_1 chimed in with a more nuanced approach, pointing out that padding settings might be the root cause of the alignment issue. He suggested that before diving into CSS, it's essential to ensure symmetric padding around the image.

He also highlighted a crucial point about where to add your CSS. Instead of directly editing the theme files (like base.css or theme.liquid), Tim_1 recommended using the "Custom CSS" section within the section settings. Here's why:

  • Specificity: Adding CSS to theme files applies it globally, potentially causing unintended side effects on other pages or elements.
  • Theme Updates: Directly modifying theme files can make future theme updates more complicated. Your customizations might be overwritten.
  • Targeted Control: "Custom CSS" in section settings applies the rule only to that specific section, giving you more control and reducing the risk of conflicts.

Tim_1 suggested using the following CSS in the "Custom CSS" section:

.image-block {padding-inline: 0;}

He also raised a great point about mobile optimization, noting that the image size might be too small on mobile devices. Always a good thing to keep in mind!

Screenshot 2026-01-05 at 11.07.55 PM

The Takeaway: A Multi-Faceted Approach

So, what's the best way to center an image on your Shopify page? It seems like a combination of approaches might be necessary:

  1. Inspect Your Padding: First, check your padding settings around the image. Ensure it's symmetrical.
  2. Targeted CSS: Use the "Custom CSS" section in the section settings to apply your CSS rules. This minimizes the risk of conflicts and simplifies theme updates.
  3. Flexbox for Centering: If padding isn't the issue, use CSS flexbox properties like align-items: center and justify-content: center to center the image within its container.
  4. Mobile Optimization: Don't forget to check how your image looks on mobile devices and adjust the size accordingly.

Ultimately, the "best" solution will depend on your specific theme and the way your page is structured. But by considering all the factors raised in this community discussion, you'll be well-equipped to get your images perfectly centered!

It's really cool to see the different perspectives and solutions offered by the Shopify community. It highlights the importance of considering all angles when tackling a seemingly simple problem like centering an image. Remember to always test your changes and consider the impact on different devices!

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools