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

前端 未结 7 1964
长发绾君心
长发绾君心 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 22:46

    By default a span is an inline element... so that's not the default behavior.

    You can make the span behave that way by adding display: block; to your CSS.

    span {
        display: block;
        width: 100px;
    }
    

提交回复
热议问题