Jump to content

Shortening the product titles in the overview with CSS

Go to solution Solved by Ziggy,

Recommended Posts

Hey, 

Since we import our articles from another platform, we have quite long titles. We would like to shorten them with Css, so that there are a maximum of 2 lines on the desktop version and a maximum of 3 lines in the mobile version, the end of the last line should end with three dots "..." and indicate that the title is longer.

Can someone help us with the CSS for this?

Thanks in advanced!

Kind regards, Paul 

Bildschirm­foto 2024-07-02 um 10.37.02.png

Bildschirm­foto 2024-07-02 um 10.37.16.png

Link to comment

Can you share your website URL and this page?

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment
  • Solution

Here's the CSS you need:

// desktop line clamp
@media only screen and (min-width:768px) {
  .products.collection-content-wrapper .grid-main-meta .grid-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}
// mobile line clamp
@media only screen and (max-width:767px) {
  .products.collection-content-wrapper .grid-main-meta .grid-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
} 

If that worked, please let me know!

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment
20 hours ago, Paul_Wille said:

Works perfectly fine, thanks for your help!

Great! Could you mark my post as the solution and give it a like? Thanks!

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

 Did I help? Buy me a coffee?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.