Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> <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.wordBreak = "break-all"; } </script> </body> </html>