I'm trying to make inner div with fluid width and ...
when overflow (using ellipsis
).
Requirements:
.container
has fixed known width200px
.badge
could be any width but max is30px
. This is because this div contains a number (from 0 to 999). This must stayright
(float right)..content
and.badge
must be in same line.content
will 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;
}