CSS Multi Line ellipsis Cross Browser

前端 未结 5 556
小蘑菇
小蘑菇 2021-01-22 09:39

There is a \"div\" in my webpage that has fixed width and height.

Following css only works with single line text:

overflow: hidden;
text-overflow: ellips         


        
5条回答
  •  有刺的猬
    2021-01-22 09:40

    Try this example:

    display: block; /* Fallback for non-webkit */
    display: -webkit-box;
    max-width: 400px;
    height: $font-size*$line-height*$lines-to-show; /* Fallback for non-webkit */
    margin: 0 auto;
    font-size: $font-size;
    line-height: $line-height;
    -webkit-line-clamp: $lines-to-show;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    

    http://codepen.io/martinwolf/pen/qlFdp

    or go for dotdotdot.js

提交回复
热议问题