You can center one line of text by simply wrapping it in a <span> and giving it a width.
<div class='box'> <span>one line of text</span> </div> div.box > span { width: 100%; }
OR, you can apply the justify-content property to the flex container:
.box { display: flex; align-items: center; justify-content: center; height: 40px; font-size: 16px; width: 150px; border: 1px solid black; margin-bottom: 40px; text-align: center; overflow-y: hidden; }
In terms of adding an ellipsis ("...") to the text overflow, yes, it is possible, but it is difficult with multi-line text.
CSS has a text-overflow property that takes several values, including ellipsis . Unfortunately, ellipsis only works with single-line text.
CSS does not provide a standard way to apply ellipsis to multiline text. There are various workarounds, but they can be hit and skipped depending on the method and situation. See My answer here for more details: Applying an ellipse to multi-line text
source share