显示段落的第一行 [英] Show first line of a paragraph

查看:127
本文介绍了显示段落的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多行段落的DIV。

I have a DIV with a multi-line paragraph.

有任何方式(可能使用jQuery)只显示段落的第一行,其他?

Is there any way (maybe using jQuery) to only show the first line of the paragraph and hide the others?

推荐答案

没有一个明确的方法来指定第一行。建议改变DIV的高度使用CSS只显示第一行。在我看来,它是最简单的解决方案。如果你随后要更改为使用javascript显示整行,只需使用它将DIV的高度更改回100%即可。

There is not an outright way to do this by specifying the first line. I would suggest changing the height of the DIV using CSS to only show the first line. It would seem to me to be the simplest solution. If you then want to change to show the whole line with javascript just use it to change the height of the DIV back to 100%.

EDIT :我立即纠正,我不知道有一个一线伪类。但是更改高度可能仍是最简单的方法。

EDIT: I stand corrected, I was not aware that there was a first-line pseudo class. However changing the height may still be the simplest way.

这篇关于显示段落的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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