Clamping lines without '-webkit-line-clamp'

前端 未结 4 1327
野趣味
野趣味 2020-12-15 17:12

In the good old days, there existed a trick in webkit for clamping lines using pure css:

display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient:          


        
4条回答
  •  太阳男子
    2020-12-15 17:38

    Try using this CSS

    .line-clamp:after {
    background: linear-gradient(to right, rgba(255, 255, 255, 0), #FFFFFF 50%) repeat scroll 0 0 rgba(0, 0, 0, 0);
    bottom: 0;
    content: "...";
    font-weight: bold;
    padding: 0 20px 1px 45px;
    position: absolute;
    right: 0;}
    
    .line-clamp {
    height: 5.6em;
    line-height: 1.4em;
    overflow: hidden;
    position: relative;}
    

提交回复
热议问题