813 B
813 B
title, type, tags, cover, dateModified
| title | type | tags | cover | dateModified | |
|---|---|---|---|---|---|
| Truncate text | snippet |
|
houses-rock-sea | 2020-12-30T15:37:37+02:00 |
Truncates text that is longer than one line, adding an ellipsis at the end (…).
- Use
overflow: hiddento prevent the text from overflowing its dimensions. - Use
white-space: nowrapto prevent the text from exceeding one line in height. - Use
text-overflow: ellipsisto make it so that if the text exceeds its dimensions, it will end with an ellipsis. - Specify a fixed
widthfor the element to know when to display an ellipsis. - Only works for single line elements.
<p class="truncate-text">If I exceed one line's width, I will be truncated.</p>
.truncate-text {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 200px;
}