我有 html,例如:
<div id='foo' style='background:transparent;color:white;width:120px'><p>test_text_test_text_test_text_test_text_test_text_test_text_test_text</p></div>
如果字符串宽度超过 120,我如何设置它的字符串 '\n'?对于前。可能是这样的:
<div id='foo' style='background:transparent;color:white;width:120px'><p>test_text_test_text\n_test_text_test_text\n_test_text_test_text\n_test_text</p></div>
我将非常感谢你的帮助
最佳答案
你应该使用 css 属性 - 自动换行
word-wrap:break-word;
示例:http://www.w3schools.com/cssref/tryit.asp?filename=trycss3_word-wrap
关于javascript - 更改 html 字符串宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13141676/