HTML / CSS:指定< span>中的行数 [英] HTML/CSS: Specify number of lines inside <span>

查看:1777
本文介绍了HTML / CSS:指定< span>中的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP-Webapp和一个span,看起来像这样:

I have a PHP-Webapp and a span, that looks something like this:

< span><?= $ text < / span>

我想确保span只有一行。因此,如果文本太长,我不想显示最后的单词。我可以使用HTML / CSS吗?或者我必须用PHP / Javascript缩短文本吗?

I would like to make sure, that the span has only one line. So if the text is too long, I would like to not show the last words. Can I do that using HTML/CSS? Or do I have to shorten the text with PHP/Javascript?

推荐答案

文本溢出:省略号是CSS3,只会显示

The text-overflow: ellipsis is CSS3 and will only be supported in modern browsers, so in older ones you will get a nasty mid-letter/word cut off at the end.

span{display: block; width: 100px; overflow: hidden; word-wrap: break-word; text-overflow: ellipsis;}

这篇关于HTML / CSS:指定&lt; span&gt;中的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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