JavaScript 参考手册
Style overflowX 属性
如果文本溢出元素的内容区域,则提供水平滚动
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <style> #myDIV { border: 1px solid black; background-color: lightblue; width: 200px; height: 210px; white-space: nowrap; } </style> </head> <body> <p>点击“尝试一下”按钮,改变 DIV 元素的 overflowX 属性:</p> <button onclick="myFunction()">尝试一下</button> <div id="myDIV"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, <br> sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.<br> Ut wisi enim ad minim veniam,<br> quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </div> <script> function myFunction() { document.getElementById("myDIV").style.overflowX = "scroll"; } </script> </body> </html>
运行结果:
点击运行 »