I am trying to build a fluid content width with text ellipsis.. I found this question: Fluid width with text-overflow ellipsis
My requirements are almost the same, but :
.container
has fixed known width 320px.extra-text
(.badge inside the previous question) could be any width but should not be more then 60px.content
and.extra-text
must be wrap as a paragraph, and cannot be more then 2 lines with a max-height of 44px; .extra-text will be at the end of second line if.content
has a lot of text.content
could be one word or long text and will have ellipsis to be contained inside.container
if it is a long text
Browser supports : IE9
.container {
width: 320px;
max-height: 44px;
position: relative;
background: #e2e2e2;
text-align: center;
}
/** Demo */
.container + .container {
margin-top: 1rem;
}
<div class="container">
<span class="content">TITLE</span>
<span class="extra-content">extra-text</span>
</div>
<div class="container">
<span class="content">ANOTHER LONGER LONG LONG LONG LONG LONG LONG LONG LONG TITLE</span>
<span class="extra-content">extra-text</span>
</div>
So in second block the latest words "LONG TITLE" should be ellipsis and extra-text should be there..
EDIT for precision :
Here a "spec" of what I need :
+-------------------+
|lorem ipsum example|
|lorem ipsum example|
|lorem ... extra-txt|/* Content is long, "..." is need to display extra-txt */
+-------------------+
+-------------------+
|lorem extra-txt |/* Here content is short so I don't need ellipsis. */
+-------------------+