I have an interesting challenge in making two inline text elements behave in a particular way. Here are my parameters:
- The main text on the left will vary in width, from about 30-60% of the parent width.
- The supplementary text on the right will vary drastically from 20-120% of the parent width.
- Parent width is responsive-ish and can shrink to 75% of its full width. Absolute positioning won't do.
- Whenever both items don't fit, I want MAIN TEXT to remain fully visible (no ellipsis) and supplementary text to hide the overflow:
- overflow: hidden
- text-overflow: ellipsis
Both the CSS and HTML are completely available for modification, though I'd prefer if the HTML remained semantic. Feel free to use JS/jQuery if there's a nice way of doing it.
http://jsfiddle.net/gksfwozz/1/
.outer {
width: 200px;
background-color: skyblue;
border: 3px solid skyblue;
display: flex;
justify-content: space-between;
}
.left {
background-color: salmon;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.right {
background-color: blanchedalmond;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<div class="outer">
<div class="left">
MAIN TEXT
</div>
<div class="right">
additional info sdjkfhsdf
</div>
</div>