【发布时间】:2018-04-19 16:43:18
【问题描述】:
在 html 中,我有一个按钮,其中包含两个图标和一个带文本的 span。 在 css 中,我使用 flex 和 overflow 属性来截断太长的文本。该代码适用于除 IE 之外的所有浏览器。 这是 jsfiddle 上的示例:https://jsfiddle.net/fu6kfhw9/1/
HTML
<button>
<div class="container">
<i class="fa fa-file-pdf-o" aria-hidden="true"></i>
<span>TestTestTestTest</span>
<i class="fa fa-file-pdf-o" aria-hidden="true"></i>
</div>
</button>
CSS
body, button {
max-width: 100px;
}
.container {
width: 100%;
display: flex;
span {
flex: 1;
overflow: hidden;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
提前致谢, 标记
【问题讨论】:
标签: html css internet-explorer flexbox