【发布时间】:2018-10-18 20:26:56
【问题描述】:
我知道这听起来很奇怪,但我需要在字符串的左侧完成这个:
https://css-tricks.com/snippets/css/truncate-string-with-ellipsis/
例如:我需要用“...olleH”代替“Hello...”
有人知道有没有办法做到这一点?提前致谢。
【问题讨论】:
-
你试过用{方向:rtl; } CSS 属性。
我知道这听起来很奇怪,但我需要在字符串的左侧完成这个:
https://css-tricks.com/snippets/css/truncate-string-with-ellipsis/
例如:我需要用“...olleH”代替“Hello...”
有人知道有没有办法做到这一点?提前致谢。
【问题讨论】:
.truncate_class {
overflow: hidden;
width: 60px;
direction: rtl;
margin-left: 15px;
white-space: nowrap;
}
.truncate_class:after {
position: absolute;
left: 0px;
content: "...";
}
<p class="truncate_class">12154543554534351432123</p>
【讨论】:
使用dir: rlt 只会交换默认的从左到右布局。
要向后翻转每个字母,您需要 unicode-bidi 属性。
.toTruncate {
direction: rtl;
unicode-bidi: bidi-override;
max-width: 50px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
<p class="toTruncate">Hello John Doe</p>
【讨论】: