javascript - 固定跨度双重外观和字母切割
问题描述
你好,我正在尝试使跨度允许我在中间修剪太长的单词:
但问题是如果单词很长,字母会在中间被剪掉:
如果这个词很短,它会出现两次:
CSS:
#attachmentfile span {
white-space: nowrap;
overflow: hidden;
display: inline-block;
}
#attachmentfile span:first-child {
width: 50%;
text-overflow: ellipsis;
}
#attachmentfile span + span {
width: 50%;
direction: rtl;
text-align: right;
}
html:
<span>
{{Att}}
</span>
<span>
{{Att}}
</span>
示例:http: //jsfiddle.net/c8everqm/1/
解决方案
CSS:
#fileName span {
white-space: nowrap;
overflow: hidden;
display: inline-block;
}
#fileName span:first-child {
width: 100px;
text-overflow: ellipsis;
}
#fileName span + span {
width: 1px;
direction: rtl;
text-align: right;
text-overflow: ellipsis;
}
HTML:
<div id="fileName"><span>This is the big name of my file.txt</span><span>This is the big name of my file.txt</span>
</div>
多亏了freedomn-m
这一点,我才找到了解决方案。
推荐阅读
- google-bigquery - 从 ValueProvider 读取的 Dataflow BigQuery:“StaticValueProvider”对象没有属性“projectId”
- java - 将 JLayerPane 添加到 JFrame 时延迟
- oracle - 如何在 SSMA 工具上连接到 Oracle?
- c# - 底层压缩例程无法保留足够的内存
- bash - 解析长命令行参数不适用于 getopt
- azure - 如何从 VM 中删除自托管集成运行时?
- javascript - VisualStudioCode 不接受我的 JavaScript 文件
- oracle - 运行使用嵌套表的存储过程时调用中的参数数量或类型错误
- audio - 共享音频android 11
- php - Symfony sqlite 迁移注册添加唯一约束