Magento edit responsive css to rearrange column

Magento edit responsive css to rearrange column

September 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento edit responsive css to rearrange column

Rearranging Columns for Responsive Magento Product Pages

The Problem: Mobile Layout Issues

You’re facing an issue where your Magento product page is displaying incorrectly on mobile devices. The product details column (col-main) appears after the sidebar column (col-right), which contains secondary content like related products and advertisements. This layout reversal causes a poor user experience, especially for mobile users who expect to see the primary content first.

Understanding the Responsiveness Issue

To resolve this, we need to dive into the responsive design techniques used by your theme. Most likely, the theme is using media queries to adjust the layout based on screen size. The default Magento blank template uses a two-column layout for desktop and a single column layout for mobile.

The key challenge is that the theme applies these changes globally, which doesn’t account for the unique content structure of a product page. This leads to the sidebar appearing before the main product details in smaller viewports.

The Solution: Targeted CSS Overrides

To fix this issue, we can use targeted CSS overrides to ensure that the main product column appears first on mobile devices. Here are the steps:

Step 1: Identify the Responsiveness Breakpoint

First, you need to determine at what screen width the layout changes from two columns to one. This is usually defined in pixels and depends on your theme’s specific styles.

In this case, looking at the provided CSS snippet, the breakpoint appears to be around 640px based on the @media (max-width: 640px) rule found near the end of the file.

Step 2: Target the Main Content Column

Next, we need to target the .col-main class that wraps the product details content. This is typically defined within a container like .container or wrapped inside another column class like .col-md-9.

The goal here is to ensure that this main content column appears above any other content columns (like the sidebar) when the screen size falls below the breakpoint.

Step 3: Apply Custom CSS for Mobile

We can add custom CSS rules within a media query targeting screens smaller than our identified breakpoint. This will override any conflicting styles applied by the theme’s global responsive styles.

Here’s an example of what this targeted rule might look like:

@media (max-width: 640px) {
    .maincontent .col-md-12 .row > .col-main {
        order: -1;
    }
}

This rule targets the .col-main element when it’s a direct child of a .row inside a container on mobile screens. The order: -1; property ensures this column appears before any other columns in the flow.

Applying the Fix

To implement this fix, you can add this custom CSS code to your theme:

Option A: Add to Theme’s Existing CSS File

If your theme has an existing css/responsive.css or similar file, you can simply add this rule within the appropriate media query section of that file.

Option B: Create a Custom CSS File

Alternatively, if your theme doesn’t have separate responsive styles, or you want to avoid modifying core files, you can create a new custom CSS file. This could be named something like css/overrides.css and included via the Magento layout XML.

In either case, make sure this rule is applied only on the product page template where this issue occurs (not globally), so it doesn’t conflict with other page layouts in your store.

Testing the Fix

After adding this fix:

  1. Save the CSS file.
  2. Clear the cache via Magento’s admin system or a tool like Magento’s built-in magento cache:clean command-line tool.
  3. Visit the product page on a mobile device or inside a browser’s developer tools with mobile viewport emulation enabled.

You should now see that the main product details column appears before any sidebar content when viewing the page on small screens.

Final Thoughts

This fix demonstrates how to apply targeted CSS overrides to resolve layout issues in Magento themes. By understanding your theme’s specific responsive styles and applying custom rules within appropriate media queries, you can ensure a more consistent user experience across different device sizes.

Remember, always test these changes thoroughly before deploying them to a live site. And consider using a version control system like Git for managing your CSS overrides if you’re not already doing so.

For more in-depth guides on Magento development and customization, be sure to check out the resources available at Laravel Company. They provide comprehensive tutorials and documentation to help you master all aspects of this powerful e-commerce platform.

Catalog Themes Customers Errors

Our network