html - 带有文件扩展名的文本溢出省略号
问题描述
我正在制作上传功能。我必须显示刚刚上传的文件的名称。
File Name.txt
但是名字太长的时候会这样显示
File Name Is Too Long...txt
我尝试使用省略号
.file-name {
overflow: hidden;
text-overflow: ellipsis
}
但我不知道文件扩展名。
解决方案
设法使用flex提出了这个:
.filename {
max-width: 200px;
display: flex;
}
.name {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
<div class="filename">
<span class="name">File Name Is Too Long.</span>
<span class="extension">txt</span>
</div>
<div class="filename">
<span class="name">This filename is also too long.</span>
<span class="extension">txt</span>
</div>
推荐阅读
- c# - AuthenticationBuilder 不包含“AddMicrosoftIdentityWebApp”的定义
- windows - 在 Windows 10 上运行我的狂欢应用程序失败
- node.js - 使用 Ganache-Cli、Mocha、Web3、Solc 0.8.6 编译器运行智能合约
- android - 如何在华为设备上进行深度链接?
- chef-infra - 不给出预期结果的秘诀
- struct - 如何在 Solidity 中将结构保存在数组中?
- c++ - linux cn_proc proc_event 值很奇怪
- html - 如何使用此比率自动调整 2 个并排 iframe 的大小?
- sql - 使用具有每日日期的列按月分组
- javascript - 将同一数组内的多个对象合并为一个对象,其中重复属性可能在结果对象中重复