Alternative to using flexbox for truncating text
To achieve a truncated text effect without relying on flexbox, you can set the height of the text container and utilize the webkit-line-clamp property as shown below:
.line-clamp-3 {
display: block;
display: -webkit-box;
height: 50px;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
The text will be displayed in a truncated manner like this:
https://i.stack.imgur.com/fDyYL.png
Flexbox solution for truncating text
If you prefer using flexbox for truncating text, you can refer to this guide for implementation details: https://css-tricks.com/flexbox-truncated-text/
.flex-parent {
display: flex;
}
.short-and-fixed {
width: 30px;
height: 30px;
}
.long-and-truncated {
margin: 0 20px;
flex: 1;
min-width: 0;
}
.long-and-truncated span {
display: inline;
-webkit-line-clamp: 3;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
word-wrap: break-word;
}
<div class="flex-parent">
<div class="flex-child short-and-fixed">
</div>
<div class="flex-child long-and-truncated">
<span>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span>
</div>
<div class="flex-child short-and-fixed">
</div>
</div>