I'm trying to achieve the following layout (please see the screenshot below).
B can be included into the SPAN - but it didn't help me. I was also trying to use tables, even nested ones - nothing helps..
Expected behavior:
Initial snippet:
div {
width: 200px;
white-space: nowrap;
border: 1px solid red;
margin-top: 10px;
}
span {
overflow: hidden;
text-overflow: ellipsis;
}
b {
padding-left: 10px;
}
<div>
<span>test</span>
<b>12345</b>
</div>
<div>
<span>test test test test test test test test test test test</span>
<b>50</b>
</div>
Just add display: flex
to the div container:
div {
display: flex; /* new */
width: 200px;
white-space: nowrap;
border: 1px solid red;
margin-top: 10px;
}
span {
overflow: hidden;
text-overflow: ellipsis;
}
b {
padding-left: 10px;
}
<div>
<span>test</span>
<b>12345</b>
</div>
<div>
<span>test test test test test test test test test test test</span>
<b>50</b>
</div>
A combination of flex default settings, including flex-shrink: 1
, enable the ellipsis to render in a flex formatting context.