CSS word ellipsis ('…') after one or two lines

前端 未结 9 2058
执笔经年
执笔经年 2021-01-01 23:40

I\'m trying to create a word-wrap in JavaScript using CSS, and the condition is:

If DIV contains one very long word, such as \"asdasfljashglajksgkjasghk

9条回答
  •  青春惊慌失措
    2021-01-02 00:21

    Hope this answers your question

      @mixin multilineEllipsis(
      $lines-to-show: 2,
      $width: 100%,
      $font-size: $fontSize-base,
      $line-height: 1.6) {
    
      display: block; /* Fallback for non-webkit */
      display: -webkit-box;
      max-width: $width;
      height: $font-size * $line-height * $lines-to-show; /* Fallback for non-webkit */
      font-size: $font-size;
      -webkit-line-clamp: $lines-to-show;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    

    http://codepen.io/martinwolf/pen/qlFdp http://caniuse.com/#search=-webkit-line-clamp

提交回复
热议问题