根据像素的宽度缩短长文本 [英] Shorten long text according to width in pixels

查看:130
本文介绍了根据像素的宽度缩短长文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想缩短非常长的描述到可用的表列宽度。我有像素的列宽度信息。现在我想将此度量转换为字符数,因此我可以将文本缩短为指定的数字。



我不必是100%正确的,一个接近的假设也将起作用。

解决方案

他谈论的CSS属性是文本溢出 p>

尝试将以下内容添加到您的元素的类中,全部都是必需的:

 溢出:隐藏; 
文本溢出:省略号;
white-space:nowrap;


I would like to shorten very long descriptions to the available table column width. I have the column width information in pixels. Now I would like to convert this measure to the number of characters, so I can shorten the text to the specified number.

I doesn't have to be 100% correct, a near assumption will also work.

解决方案

The CSS property that he is talking about is "text-overflow".

Try adding the following to you element's class, all are required:

overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

这篇关于根据像素的宽度缩短长文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆