執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #myDIV { width: 400px; height: 200px; background-color: lightblue; border: 1px solid black; } </style> </head> <body> <h1>Change white-space with JavaScript</h1> <p>Click the "Try it" button to make sure that the text inside the DIV element never wraps:</p> <button onclick="myFunction()">Try it</button> <div id="myDIV"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </div> <script> function myFunction() { document.getElementById("myDIV").style.whiteSpace = "nowrap"; } </script> </body> </html>