How do you wrap long words on newline, and avoid horizontal scroll using CSS?

前端 未结 3 546
南笙
南笙 2021-01-11 17:17

I have the folowing html:

long text here

and css:

.box {
    width: 400px;
    h         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 18:03

    For custom word breaking, there is an html special character that is not so often used- ­ (soft hyphen) - that will split words on 2 lines and insert a dash after the first part of the word if the word approaches the edge of its container. Trouble is, you'll have to place them everywhere you want them. As you say, though, you can also set up a js or php function, and insert them into the appropriate places.

提交回复
热议问题