gpt4 book ai didi

javascript - 更改 html 字符串宽度

转载 作者:太空宇宙 更新时间:2023-11-04 00:10:46 25 4
gpt4 key购买 nike

我有 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com