CSS Multi Line ellipsis Cross Browser

前端 未结 5 559
小蘑菇
小蘑菇 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:51

    To bad CSS doesn't support cross-browser multiline clamping, only WebKit seems to be pushing it. Any other hacky solutions don't really seem worth it at the moment because even they have their own issues.

    I know how you want pure CSS and probably have your own Javascript alternative options but you could try and use a simple Javascript ellipsis library like Ellipsity on github the source code is very clean and small so if you do need to make any additional changes it should be quite easy.

    https://github.com/Xela101/Ellipsity

    I'm really wanting a pure CSS solution to this too to speed things up and make everything look more pretty without the need of external dependencies.

提交回复
热议问题