converting white space into line break

后端 未结 2 468
無奈伤痛
無奈伤痛 2021-01-18 02:19

Is it possible to add a line break on each white space using CSS?

For example, if I have string \"Format It\" I would like to display it like

         


        
2条回答
  •  不知归路
    2021-01-18 03:02

    You can use the word-spacing property. It defines the space between the words. If you set it to the size of the container, it will force a line break...

    Since it doesn't accept percentual values, you can use relative values like vw.

    div {
        word-spacing: 100vw;
    }
    

    http://jsfiddle.net/ApL3h/

提交回复
热议问题