<html>
<head>
<title></title>
<style>
p {
width:0.5*;
overflow-x:hidden;
white-space:nowrap;
text-overflow:path-ellipsis;
border:1px solid;
}
</style>
<script type="text/tiscript"></script>
</head>
<body>
Change window size to see ellipsis:
<p>/temp/pretty long/path/to the file.ext</p>
Does not contain path separators - rendered as text-overflow:ellipsis :
<p>temp pretty long path to the file.ext</p>
</body>
</html>

本文探讨了如何使用CSS样式解决长文本在限定宽度内的显示问题,通过设置宽度、隐藏溢出文本及使用省略号表示未显示部分,实现文本的优雅截断。
785

被折叠的 条评论
为什么被折叠?



