Can CSS Create an Ellipsis on the Second Line of Text?
Dec 09, 2024 pm 06:42 PMCSS ellipsis on Second Line: Is it Feasible?
In CSS, text-overflow: ellipsis is widely used to indicate truncated text with an ellipsis (...). However, implementing ellipsis on the second line of a multi-line text block has long been a challenge.
To achieve this effect, rather than relying on text-overflow, one can consider using the -webkit-line-clamp property. This property limits the number of lines displayed within a block container. By combining it with display: -webkit-box and -webkit-box-orient: vertical, you can constrain the text to a specific number of lines. To ensure clipping, overflow: hidden is recommended.
The following code snippet exemplifies this approach:
overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
This technique utilizes -webkit prefixes, making it compatible with webkit browsers. However, it's worth noting that support for this specific combination may vary across different browser versions.
The above is the detailed content of Can CSS Create an Ellipsis on the Second Line of Text?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Adding Box Shadows to WordPress Blocks and Elements

Create a JavaScript Contact Form With the Smart Forms Framework

Create an Inline Text Editor With the contentEditable Attribute

Making Your First Custom Svelte Transition

Demystifying Screen Readers: Accessible Forms & Best Practices

Comparing the 5 Best PHP Form Builders (And 3 Free Scripts)

File Upload With Multer in Node.js and Express
