I am trying to execute a layout like this:

So, subtitles are always at least in the second line, even if they can fit in the first line next to the title. If the title is long and split into two or more lines, the subtitles should follow the title without breaking a new line.
This is what I have done so far, but this solution is not perfect:
div.data {
background:white;
position:relative;
min-height: 2em;
float:left;
max-width:150px;
margin: 50px;
}
.title {
position:relative;
overflow:hidden;
background: white;
z-index: 10;
}
.title span {
position:relative;
}
.title span span {
position:absolute;
right:0px;
opacity:1;
top: 18px;
display: block;
transform: translateX(100%);
padding-left: 5px;
color: red;
}
span.subtitle {
position:absolute;
bottom:0;
left:0;
z-index: 5;
display:block;
color: red;
}
<div class="data">
<div class="title"><span>title <span>subtitle</span></span></div>
<span class="subtitle">subtitle</span>
</div>
<div class="data">
<div class="title"><span>reaallllyyyy loooooong title <span>subtitle</span></span></div>
<span class="subtitle">subtitle</span>
</div>
Run codeHide resultSorry for the title of the question, this is the best I could come up with.
source
share