Languages
[Edit]
EN

CSS - text-overflow: ellipsis with nested display: flex elements

6 points
Created by:
DEX7RA
580

In this article, we're going to have a look at how to in a simple way in pure CSS cut overflowing text for multiple nested elements with flex-box.

Overflow text cutting in pure CSS.
Overflow text cutting in pure CSS.

Quick solution:

 

A more complicated practical example

Edit

A verry common problem when we try to make CSS shortcut for text is: when we try to combine flex-box layout (display: flex;) with text-overflow: ellipsis.

The solution for this problem is to use min-width: 0 for parent element that we want to shortcut text.

Note: when div.shortcut element will be in flex-box mode (display: flex), text-overflow: ellipsis will be not working.

Conclusion: use ellipsis always with block element, wrapping text with aditional element when it is necessary.

 

Alternative titles

  1. CSS - text-overflow: ellipsis with nested display: flex elements (flexbox)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

CSS

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join