How can I wrap or break long text/word in a fixed width span?

前端 未结 7 2067
长发绾君心
长发绾君心 2020-12-22 22:27

I want to create a span with a fixed width that when I type any thing in the span like lgasdfjksdajgdsglkgsadfasdfadfasdfadsfasdfasddkgjk

7条回答
  •  轮回少年
    2020-12-22 23:01

    In my case, display: block was breaking the design as intended.

    The max-width property just saved me.

    and for styling, you can use text-overflow: ellipsis as well.

    my code was

    max-width: 255px
    overflow:hidden
    

提交回复
热议问题