How can I adjust product title length for uniform 'Add to Cart' positioning?

Topic summary

Goal: Make product titles a consistent height so “Add to Cart” buttons align across product cards.

What was tried:

  • CSS added to clamp titles to two lines using -webkit-line-clamp with overflow hidden.
  • Additional CSS enforcing single-line truncation (white-space: nowrap; text-overflow: ellipsis) was also present.
  • Multiple variations tested; screenshots provided; site URL shared for context.

Proposed fix:

  • New CSS targeting .product-grid–title a with min-height and -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden.

Latest outcome:

  • Mobile displays as intended.
  • Desktop still shows only one line of title instead of two.
  • The template also applies {{ product.title | truncate: 30 }}, which shortens titles to 30 characters and may interact with line clamping.

Key technical notes:

  • -webkit-line-clamp limits text to a set number of lines in a flex-like WebKit box.
  • white-space: nowrap forces a single line, which conflicts with multi-line clamping.
  • The Liquid filter truncate limits character count regardless of CSS.

Status and open items:

  • Not fully resolved. Clarification needed on whether to remove the single-line CSS and/or adjust/remove the truncate filter to allow two lines on desktop.
Summarized with AI on January 4. AI used: gpt-5.

Hi all,

I would like to make all the product titles have the same length in product title so the ADD TO CART can stay at the same level.

I have tried to put this at the theme.css

#main-collection-product-grid .product-item__title {
     display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
     overflow: hidden;
}
.product-item__title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

I also tried

and

but it still doesn’t work.

www.nominalhk.com here is the url

Does anyone know which part did I make a mistake on?

Thanks a lot!

@davidwu1604 Please use below CSS code in your theme.css

.product-grid--title a {
    min-height: 44px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

Please let me know when work and like and mark as solve!

hi do I still need to keep this as well?

{
.product-item__title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
}

now it looks like this

on mobile is excellent, but on desktop only sees one line instead of two.

i have keep this following:


 

  

    

      {% if show_vendor %}
        
{{ product.vendor }}

      {% endif %}
      

        {{product.title | truncate: 30}}
      

thanks!

@davidwu1604 If i helped you please like and mark as solve! Thanks

1 Like