Mastering Shopify Background Images: Positioning & Text Overlays with CSS

Hey everyone! As a Shopify migration expert and someone who loves digging into what makes your stores tick, I spend a lot of time in the community forums. It's a goldmine of real-world problems and ingenious solutions from fellow store owners and developers. Recently, I stumbled upon a thread that perfectly illustrates a common design challenge: getting your background images and overlaying text to sit just right.

It started with a store owner, Pale_September, who was trying to perfect their password page. They had a beautiful background image for a section and wanted to align it to the top-left. The real trick, though, was then positioning their text box (like a heading and paragraph) precisely within that image, almost like a custom banner. Take a look at the vision they shared:

Screenshot 2026-05-14 at 17.19.04

The Community Weighs In: Different Angles to the Same Problem

What I love about these discussions is how different experts approach the same issue. We saw a few great suggestions pop up, each with its own merits.

Approach 1: Targeting the Background Itself

Ecommerce_expert_AP jumped in with a solid recommendation to adjust the actual background positioning directly on the section container. This is a classic CSS technique for elements that use a background image property.

They suggested something like this:

.banner,
.password-main {
  background-position: top left !important;
  background-size: cover;
}

.banner__content {
  padding-top: 80px;
  padding-left: 120px;
}

The core idea here is to tell the browser: "Hey, for this section (like .banner or .password-main), make sure its background image starts exactly from the top-left corner and covers the entire area." Then, you use padding on the text container (.banner__content) to push the text where you want it. A really important point Ecommerce_expert_AP raised was to always check mobile responsiveness, as fixed padding can sometimes cause layout issues on smaller screens.

Approach 2: Using Object Properties for Images

devcoders offered a slightly different angle, focusing on the tag itself if the image is embedded directly. This is super useful when you're not dealing with a CSS background image but an actual HTML image element.

Their snippet, to be added to your Asset > base.css file, was:

.background-image-container img { object-position: top left; object-fit: cover; }

Here, object-position and object-fit are powerful properties for controlling how an element's content is sized and positioned within its own content box. It's a great modern CSS approach!

Approach 3: The Comprehensive, Responsive Solution

Then came tim_1 with a robust solution that seemed to hit all the marks, likely the "perfectly" working one Pale_September mentioned. This approach combines image positioning with detailed text padding and importantly, includes media queries for responsiveness.

tim_1 suggested adding this code to the "Custom CSS" setting of the specific section:

h2 { padding: 100px 0 30px 120px;  }
p  { padding-left: min(20%, 120px);}

@media (min-width:750px){
  h2 { padding: 25px 0 30px 350px; }
}

img {
  width: 350px !important;
  max-width: 70%;
  
  object-position: left top;
}

.background-image-container {
    padding-left: calc( 50% - var( --page-width)/2 );
}

This code does a few things:

  • It directly targets the h2 and p elements for padding, pushing them into position.
  • The min(20%, 120px) for paragraph padding is a clever way to make it responsive: it will take 20% of the parent width, but never more than 120px, ensuring it doesn't stretch too far on wide screens or get too cramped on small ones.
  • A @media query adjusts the h2 padding for wider screens (min-width:750px), showing how to adapt for different devices.
  • It sets object-position: left top; for the img, similar to devcoders' suggestion, confirming the image positioning.
  • Finally, it uses calc() and a CSS variable (--page-width) to center the .background-image-container itself, a more advanced responsive technique.

Here are the screenshots tim_1 shared, illustrating the effect:

Screenshot 2026-05-15 at 11.47.57 AM

Screenshot 2026-05-15 at 11.52.51 AM

Putting It Into Practice: How You Can Do This

Based on the success of tim_1's detailed approach, here's how you can implement similar custom CSS for your Shopify store:

  1. Identify Your Section: First, you need to know which section you're targeting. For Pale_September, it was a section on their password page. You might be targeting a banner section on your homepage or a custom content block.
  2. Access Your Theme Editor: Go to your Shopify Admin > Online Store > Themes. Click "Customize" on your current theme.
  3. Find the Custom CSS Option: Navigate to the specific section in the editor. Many modern Shopify themes have a "Custom CSS" or "Custom Liquid" box within the section settings in the theme editor. This is the easiest place to paste code that only applies to that section.
  4. Alternatively, Edit Theme Code: If your theme doesn't have a section-specific custom CSS box, or if you want the CSS to apply more broadly, you'll need to go to Actions > Edit code from your Themes page. Look for a CSS file like base.css, theme.css, or custom.css within the "Assets" folder. You can usually paste custom code at the very bottom of one of these files.
  5. Paste and Adapt the Code: Use a snippet like tim_1's as a starting point. Remember to adjust the padding values (100px 0 30px 120px, min(20%, 120px), etc.) to fit your specific image and desired text position. The class names (e.g., h2, p, img, .background-image-container) are generally standard HTML tags, but your theme might wrap them in specific custom classes (like .banner__content from Ecommerce_expert_AP's example). You might need to inspect your page's elements using your browser's developer tools (right-click > "Inspect") to find the exact class names for your headings, paragraphs, or image containers.
  6. Test Responsiveness: This is CRUCIAL! Once you've applied the CSS, resize your browser window or use your browser's developer tools to simulate different mobile devices. Make sure your image and text look good and are still legible on all screen sizes. Adjust your padding and potentially add more @media queries as needed.

Key Takeaways for Your Store

This discussion really highlights a few important lessons for anyone customizing their Shopify store:

  • Separate Concerns: It's often best to handle image positioning and text positioning as distinct tasks, even if they contribute to one visual goal.
  • Responsiveness is Non-Negotiable: Always, always consider how your design will look on mobile. Tools like min(), calc(), and @media queries are your best friends here.
  • Theme Specifics: Keep in mind that class names (like .banner, .password-main, .banner__content) can vary between themes. A little inspection with browser dev tools goes a long way.
  • Community Power: Don't hesitate to ask for help or search the Shopify Community forums. Chances are, someone else has faced a similar challenge and found a clever solution!

Customizing your Shopify store to get that perfect look and feel can sometimes feel like a puzzle, but with a little CSS know-how and the collective wisdom of the community, you can achieve really stunning results. Happy customizing!

Share:

Use cases

Explore use cases

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

Explore use cases