and*_*rsh 3 html css html-table ellipsis wkhtmltopdf
我正在尝试实现以下布局(请参见下面的屏幕截图)。
B 可以包含在 SPAN 中 - 但这对我没有帮助。我还尝试使用表格,甚至是嵌套的表格 - 没有任何帮助。
预期行为:
初始片段:
div {
width: 200px;
white-space: nowrap;
border: 1px solid red;
margin-top: 10px;
}
span {
overflow: hidden;
text-overflow: ellipsis;
}
b {
padding-left: 10px;
}Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
只需添加display: flex到 div 容器:
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;
}Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
Flex 默认设置的组合(包括flex-shrink: 1)使省略号能够在Flex 格式化上下文中呈现。