Truncate a string nicely to fit within a given pixel width

后端 未结 4 886
南笙
南笙 2020-12-04 16:14

Sometimes you have strings that must fit within a certain pixel width. This function attempts to do so efficiently. Please post your suggestions or refactorings below :)

4条回答
  •  被撕碎了的回忆
    2020-12-04 16:39

    Luckily, CSS3 text-overflow should eventually take care of that.

    If anyone is using ASP.NET and is interested in a server-side solution, check this blog post:

    http://waldev.blogspot.com/2010/09/truncate-text-string-aspnet-fit-width.html

提交回复
热议问题