I'm trying to make inner div with fluid width and ... when overflow (using ellipsis).
Requirements:
.containerhas fixed known width200px.badgecould be any width but max is30px. This is because this div contains a number (from 0 to 999). This must stayright(float right)..contentand.badgemust be in same line.contentwill have ellipsis and nowrap. Must stayleft- Key important:
.content's width =.container's width -.badge's width
I could not get #5 above to happen. Any pointer?
My code below either made the .badge to wrap in second line or the .content just doesn't expand its width.
HTML:
<div class=container>
<div class=content>
Donec id elit non mi porta gravida at eget metus
</div>
<div class=badge>
5
</div>
</div>
CSS:
.container {
width: 200px;
background: gray;
}
.content {
display: inline-block;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
max-width: 170px;
background: green;
}
.badge {
display: inline-block;
max-width: 30px;
background: yellow;
float: right;
}