How to use CSS text-overflow on text that's wrapping?

后端 未结 2 1282
-上瘾入骨i
-上瘾入骨i 2020-12-31 01:40

Does anybody know of a way to use {text-overflow: ellipsis;} on a piece of text that\'s wrapping to a second line?

Adding:

{whitespace: nowrap;}
         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 02:38

    If you know the content is going to wrap to two lines every time this solution will work. Use ::after and content: '...'; and then position it over the bottom right corner of your type (which should be a block level element). This will only work if you are working against a solid background color as you need to set the background of the ::after to match.

    The only downfall is the limited parameters this can be successful in and the fact that it will cut a character in half if things don't line up right (which they probably won't).

提交回复
热议问题