Shrink title to 2 lines using CSS: Maximum of 15 words

phan tu cua wordpress 1

The CSS snippet shared aims to shorten the lengthy and uneven product names typically found in Vietnam, making them more visually appealing on the web. By using the code provided, product titles can be condensed to a specified number of lines, improving the overall look of the website. The snippet includes instructions on how to customize the code for different website themes and the desired number of lines to cut. This simple solution can enhance the aesthetics of product listings and improve the user experience for customers.

If you’re looking to tidy up the appearance of product names on your website, especially those with long and messy titles, I’ve got a nifty CSS snippet for you. This snippet will help you shorten the titles and make them look more uniform and appealing to users.

Here’s the CSS snippet you can use:

p.name.product-title a {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    padding: 0;
}

In the code above, the class p.name.product-title a refers to the product titles on your website. Make sure to replace it with the correct class used on your site (the example is based on the Flatsome theme). The property -webkit-line-clamp: 2; controls the number of lines you want to display. If you prefer to show only one line, simply change the number to 1.

Give it a shot and see how it improves the readability and layout of your product names. Good luck with your website enhancement efforts!

Rate this post
See also  Display selected posts with ACF Pro on Flatsome theme.

Related posts