Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
截断行号N CSS上的文本_Css_Sass - Fatal编程技术网

截断行号N CSS上的文本

截断行号N CSS上的文本,css,sass,Css,Sass,截断特定行上的文本(或线夹)的最佳方式是什么 假设我有一段有8行文字的段落,但我只想显示3行 这可能是通过CSS实现的,还是我需要其他东西?是的,很简单,请看下面的示例 html: <div class="i-speak-too-much"> Hello I like speak, I live in the future I am the Universe </div> .i-speak-too-much { width: 100px; white-sp

截断特定行上的文本(或线夹)的最佳方式是什么

假设我有一段有8行文字的段落,但我只想显示3行


这可能是通过CSS实现的,还是我需要其他东西?

是的,很简单,请看下面的示例

html:

<div class="i-speak-too-much">
  Hello I like speak, I live in the future  I am the Universe
</div>
.i-speak-too-much {
  width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; //making dots
  }

jsiddle:

行高
最大高度
设置为要显示的n行的倍数。例如,如果
行高
为30px,则仅显示2行:

HTML

<p class="text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>

示例

检查一下这篇文章,@Venugopal,似乎正是我想要的!我已经为这一行做了一个解决方案:是的,这适用于1行,但是想象一下,如果你的文本是7行,你想显示3。。文本溢出:省略号会打断第一行,是否可以将其更改为第n行?我知道如何将文本修剪到最大行高。但是我如何添加省略号呢?上面的代码只有在限制为1行的情况下才有效。如此简单和容易!打得好!解决问题!非常感谢。
.text {
  line-height: 30px;
  max-height: 60px;
  overflow: hidden;
}