css 多行文字溢位省略號顯示

Alone1469546971808發表於2018-12-15
/* mixin for multiline */
@mixin multiLineEllipsis($lineHeight: 1.2em, $lineCount: 1, $bgColor: white, $zIndex: 100){
  overflow: hidden;
  position: relative;
  line-height: $lineHeight;
  max-height: $lineHeight * $lineCount; 
  text-align: justify;
  &:before {
    content: '...';
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: $zIndex + 1;
  }
  &:after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 1em;
    height: 1.2em;
    z-index: $zIndex;
    margin-top: 0.2em;
    background: $bgColor;
  }
}
複製程式碼

使用

.card-text{
    @include multiLineEllipsis($lineHeight: 1.2em, $lineCount: 3, $bgColor: white, $zIndex: 100);
}
複製程式碼

相關文章