Shopify

Mastering Shopify Product Card Dimensions: A Guide to Customizing Aspect Ratios

Ever scrolled through a Shopify store and felt that the product images didn't quite capture the full essence of the item? Perhaps they were cut off, or there was too much awkward empty space, diminishing the product's appeal. You're not alone in this experience. At Shopping Cart Mover, we understand that visual presentation is paramount in e-commerce, and even subtle adjustments can make a significant difference to your store's aesthetic and conversion rates.

This very issue recently sparked a valuable discussion in the Shopify community. A fellow merchant, ecom11, operating www.marencio.com with the popular Horizon theme, sought a way to make their product cards slightly longer in height, moving beyond the default 'portrait' setting. This desire to fine-tune visual elements is a common thread among successful online businesses, and thankfully, Shopify offers the flexibility to achieve it.

Visualizing Shopify Product Card Height Adjustment with Custom CSS
Visualizing Shopify Product Card Height Adjustment with Custom CSS

Why Product Card Aspect Ratios Matter for Your Shopify Store

Before we dive into the 'how-to,' let's briefly consider the 'why.' The aspect ratio of your product cards directly impacts:

  • First Impressions: High-quality, well-framed images instantly convey professionalism and attention to detail.
  • Product Clarity: Ensuring your product is fully visible without awkward cropping helps customers understand what they're buying.
  • Brand Consistency: A uniform look across all product cards reinforces your brand identity.
  • User Experience (UX): Visually appealing and consistent layouts make for a more pleasant and trustworthy shopping experience, encouraging longer browsing sessions and higher engagement.
  • Conversion Rates: Clear, attractive product displays can significantly influence a customer's decision to add to cart.

When default theme settings don't quite align with your product photography or brand vision, a little customization can go a long way.

Understanding Shopify's Default Product Card Ratios

Shopify themes, like Horizon, typically provide a few standard aspect ratio options for product images. As tim_1, a helpful community expert, demonstrated, these are often defined within your theme's Liquid files, such as the card-gallery.liquid snippet. Here's a look at how these ratios are commonly assigned:

      assign ratio = '1'
      case block_settings.image_ratio
        when 'landscape'
          assign ratio = '16 / 9'
        when 'portrait'
          assign ratio = '4 / 5'
          assign ratio = '1'
        when 'adapt'
          assign ratio = product.featured_media.preview_image.aspect_ratio | default: '1'
      endcase

This Liquid code snippet reveals the standard choices:

  • 'square' (1:1): Perfect for products that fit a balanced, equal-sided frame.
  • 'landscape' (16:9): Wider than it is tall, ideal for broad products or horizontal compositions.
  • 'portrait' (4:5): Taller than it is wide, a common choice for apparel, jewelry, or items with vertical emphasis.
  • 'adapt': Attempts to use the original aspect ratio of your uploaded image, providing flexibility but potentially leading to inconsistent card sizes.

While these options cover most scenarios, ecom11's query highlights a common need: what if 'portrait' (4:5) isn't quite tall enough, and you need something a little longer, perhaps a 3:4 or even 2:3 ratio (width:height)?

The Solution: Customizing Product Card Height with CSS

The beauty of Shopify's modern themes is their extensibility. For subtle visual tweaks like adjusting product card height, you don't always need to delve deep into Liquid code. The most recommended and safest approach is to use custom CSS within your theme settings. This method ensures your changes are less likely to be overwritten during theme updates and keeps your core theme files pristine.

To make your product cards slightly longer, you'll be targeting a specific CSS variable that controls the aspect ratio of the gallery cards. Here's the elegant solution proposed by tim_1:

.card-gallery > .contents {
  --gallery-aspect-ratio: 0.75; /* amend the ratio to your liking */
}

Breaking Down the CSS

  • .card-gallery > .contents: This is the CSS selector that targets the container holding your product card's content, typically including the image and product details.
  • --gallery-aspect-ratio: 0.75;: This is a CSS custom property (variable) that dictates the width-to-height ratio of the product card.

Let's clarify the value: If you set `--gallery-aspect-ratio` to `0.75`, it means the width of the card will be 75% of its height. In other words, the height will be approximately 1.33 times the width. This translates to a 3:4 aspect ratio (width:height), making the card noticeably longer than the default 4:5 portrait (which is `0.8`).

  • To make cards taller (more portrait), you would use a value less than 1.
  • To make cards wider (more landscape), you would use a value greater than 1.
  • For a perfect square, use `1`.

Experiment with values like `0.8` (closer to 4:5), `0.75` (3:4), or even `0.66` (approximately 2:3) to find the perfect length for your product cards.

Step-by-Step: Implementing Custom CSS in Shopify

Applying this custom CSS to your Shopify store is straightforward:

  1. Log in to your Shopify Admin: Go to your store's backend.
  2. Navigate to Themes: In the left sidebar, click on Online Store > Themes.
  3. Customize Your Theme: Find your current theme (e.g., Horizon) and click the Customize button.
  4. Access Theme Settings: In the theme editor, look for the Theme settings icon (usually a gear or cog icon) in the bottom-left corner. Click on it.
  5. Find Custom CSS: From the Theme settings menu, select Custom CSS.
  6. Paste the Code: In the provided text area, paste the CSS snippet:
    .card-gallery > .contents {
      --gallery-aspect-ratio: 0.75; /* amend the ratio to your liking */
    }
  7. Adjust the Ratio: Change `0.75` to your desired aspect ratio value.
  8. Save Your Changes: Click the Save button in the top right corner.

Your product cards should now reflect the new height! Remember to clear your browser cache if the changes don't appear immediately.

Best Practices for Customizing Your Shopify Store

  • Always Backup Your Theme: Before making any code changes, even minor CSS, it's wise to duplicate your theme. This provides a quick rollback option if anything goes wrong.
  • Test on Multiple Devices: Ensure your custom aspect ratios look good and function correctly across desktops, tablets, and mobile phones. Responsiveness is crucial for a consistent user experience.
  • Optimize Your Images: While adjusting card dimensions, don't forget the fundamentals of image optimization. Use appropriate file formats (e.g., WebP, JPEG), compress images, and ensure they are high-resolution without being excessively large in file size. Shopify's built-in image resizing and CDN help, but starting with optimized images is best.
  • Maintain Visual Consistency: While customization is powerful, overuse can lead to a disjointed store. Strive for a consistent look and feel across all product cards and collections.
  • Review Periodically: As your product catalog grows or your theme updates, periodically review your custom CSS to ensure it still achieves the desired effect.

For merchants looking to migrate their entire store to Shopify or needing more extensive theme customizations beyond simple CSS tweaks, the experts at Shopping Cart Mover are here to help. We specialize in seamless data migration and comprehensive e-commerce solutions, ensuring your store not only looks great but performs flawlessly.

Conclusion

Customizing your Shopify product card aspect ratios is a powerful yet simple way to enhance your store's visual appeal and improve the overall shopping experience. By understanding how Shopify handles these ratios and leveraging the flexibility of custom CSS, you can ensure your products are presented in their best light. Take control of your storefront's design and watch your engagement and conversions grow!

Share:

Use cases

Explore use cases

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

Explore use cases