【发布时间】:2018-04-09 00:51:12
【问题描述】:
.left-ellipsis {
text-align: left;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
direction: rtl;
}
.left-ellipsis span {}
/* Media query for IE only. */
@media screen and (-ms-high-contrast: active),
(-ms-high-contrast: none) {
.left-ellipsis span {}
}
<strong>With overflowing content</strong>
<br>
<i>Expected to see <strong>1 0002 0003 0004 0005 end</strong></i>
<div style="border: 1px solid #666; width: 200px; padding: 5px;">
<div class="left-ellipsis">
<span dir="ltr">123 456 789 0001 0002 0003 0004 0005 end</span>
</div>
</div>
<br>
<strong>Without overflowing content</strong>
<br>
<i>Expected to see <strong>0002 0003 0004 0005 end</strong> without ...</i>
<div style="border: 1px solid #666; width: 200px; padding: 5px;">
<div class="left-ellipsis">
<span dir="ltr">0002 0003 0004 0005 end</span>
</div>
</div>
问题:我们希望在 div 左侧的溢出文本上显示省略号。
问题:该解决方案在 Chrome 和 Firefox 中运行良好,但在 IE 或 Edge 中无法正常运行。省略号正确显示在左侧,但数据是从右侧截取的,而不是从左侧截取的。
尝试:
- 我尝试在跨度中添加一个“float:right”,然后 IE/Edge 显示正确的数据,但省略号完全消失。
- 我们已经通过搜索 SO 寻找“方向”解决方案来达到这一点。它似乎适用于不错的浏览器。
非常感谢任何帮助。这是一个相当大的挑战。
编辑:这是一个人们可以尝试的小工具: https://plnkr.co/edit/AWyzZLhnLbt4DStnU5hW?p=preview
尝试使用@ovokuro 发布的文章提供的代码,我们得到chrome 来显示这个,这也不好。:
【问题讨论】:
-
@jaunt 为什么要删除我的 plunker?不允许在 SO 上使用 plunkers 吗?
-
它们是,但如果可以的话,最好使用 sn-p,因为它可以更容易地复制到答案中,不认为有一个链接也有太多目的 - 将其添加回来如果你愿意:)
-
你愿意在其中添加一些 JS 吗?
-
@andi 我想我们肯定可以。至今没用过JS。
标签: html css internet-explorer microsoft-edge