How do I only display part of a string using css

前端 未结 7 1931
梦谈多话
梦谈多话 2021-02-05 19:01

I want to be able to display a string of characters up to 10 characters. If the string goes over 10 characters, I\'d like to append \'...\' to the end.

For example, if

7条回答
  •  礼貌的吻别
    2021-02-05 19:48

    Firefox does in fact now support this, you just need to ensure that whatever you are trying to 'truncate' has block level formatting and a width - which could be the parent.

    .ellipsis {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display:block;
        width : 100px; /* this could be defined on any parent */
    }
    

提交回复
热议问题