【问题标题】:Trying to add ellipsis after the second line using sass/css? [duplicate]尝试使用 sass/css 在第二行之后添加省略号? [复制]
【发布时间】:2017-01-19 14:06:29
【问题描述】:

在 jsfiddle 链接中,您可以找到我尝试过的内容,但是当文本超过两行时,我再也看不到省略号了。有人可以帮帮我吗。我是 CSS 新手,以及如何仅使用 CSS/SASS 来解决此问题。

.exciting-text {
  display: block;
  text-overflow: ellipsis;
  word-wrap: break-word;
  overflow: hidden;
  max-height: 2em;
  line-height: 1em;
}
.exciting-text::after {
  content: "...";
  color: red;
}
<p class="exciting-text">Contributing to MDN is easy and fun.Just hit the edit button to add new live samples, or improve existing samplesdfsfssfddcdxcxdsdzxfsfdsadasdaddsadsadsadsadsadasdasfds.</p>

【问题讨论】:

  • text-overflow 仅适用于单行
  • 对不起,我应该回答这个问题:stackoverflow.com/questions/6572330/…,但如果你真的付出一些努力并在谷歌上搜索,你会遇到这个代码笔:codepen.io/martinwolf/pen/qlFdp跨度>
  • @pete,这个例子使用了 webkit,我试图不惜一切代价避免,有没有办法不使用 webkit 并感谢链接
  • 不是真的——我看到的所有例子都是 webkit、opera、js 或服务器端截断
  • 如何在 JS/nodeJS 中截断服务器端文本

标签: html css sass


【解决方案1】:

在当前示例中,您的问题是 max-height。摆脱它,您的伪省略号将始终可见。

【讨论】:

  • 嘿,谢谢你的回答,但是我想将文本限制为两行
猜你喜欢
  • 2011-07-13
  • 2015-09-24
  • 1970-01-01
  • 2020-07-22
  • 1970-01-01
  • 2023-01-11
  • 2014-07-18
  • 2013-09-15
相关资源
最近更新 更多