编辑下面的代码:【加编码】
<html> <head> <style> #myDIV { width:150px; height:100px; background-color:lightblue; border:1px solid black; } </style> </head> <body> <p>点击“尝试一下”按钮。让 DIV 元素中的长单词换行到下一行:</p> <div id="myDIV">Thiscouldbeaninsainlylargeword</div> <button onclick="myFunction()">尝试一下</button> <script> function myFunction() { document.getElementById("myDIV").style.wordWrap = "break-word"; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂