且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将空格转换为换行符

更新时间:2023-02-23 09:56:15

您可以使用word-spacing属性.它定义了单词之间的间隔.如果将其设置为容器的大小,则会强制换行...

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...

由于它不接受百分比值,因此可以使用vw之类的相对值.

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

div {
    word-spacing: 100vw;
}

http://jsfiddle.net/ApL3h/