【问题标题】:Multiline Truncation doesn't show '...' in Chrome多行截断在 Chrome 中不显示“...”
【发布时间】:2017-02-08 08:56:32
【问题描述】:

我正在使用多行截断 sass mixin。它不会在 chrome 中显示“...”。在调试时我得到了 -webkit-box-orient: vertical;没有得到应用。

下面是代码:

 overflow: hidden;
  max-height: $font-size*$line-height*$lines-to-show; /* Fallback for non-webkit */

  display: -webkit-box;
  -webkit-line-clamp: $lines-to-show;
  -webkit-box-orient: vertical;

  // Solution for Opera
  text-overflow: -o-ellipsis-lastline;

  font-size: $font-size;
  line-height: $line-height;
  text-overflow: ellipsis;

提前感谢您的帮助

【问题讨论】:

    标签: css sass multiline truncate


    【解决方案1】:

    您可以在这篇文章中找到解决方案:

    http://hackingui.com/front-end/a-pure-css-solution-for-multiline-text-truncation/

    @mixin multiLineEllipsis($lineHeight: 1.2em, $lineCount: 1, $bgColor: white){
      overflow: hidden;
      position: relative;
      line-height: $lineHeight;
      max-height: $lineHeight * $lineCount; 
      text-align: justify;
      margin-right: -1em;
      padding-right: 1em;
      &:before {
        content: '...';
        position: absolute;
        right: 0;
        bottom: 0;
      }
      &:after {
        content: '';
        position: absolute;
        right: 0;
        width: 1em;
        height: 1em;
        margin-top: 0.2em;
        background: $bgColor;
      }
    }
    

    codepen 中有一个示例,您可以在其中查看结果:

    http://codepen.io/natonischuk/pen/QbGWBa

    【讨论】:

    • 这很好用。但是如果我们不想证明文本的合理性,它会创建一个空白区域。有什么办法'...'仍然坚持出现在第三行的最后一个单词(行数 - 比如说它的 3)
    • 我认为你需要做一些 javascripting 来检测块中最新的可见词。我认为目前 css 不可能做到这一点。
    猜你喜欢
    • 2017-12-16
    • 1970-01-01
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    相关资源
    最近更新 更多