whiteSpace 属性设置如何处理文本中的空白符(比如空格和换行符)。
</>code
- Object.style.whiteSpace=normal|nowrap|pre
值 | 描述 |
---|---|
normal | 默认。空白会被浏览器忽略。 |
pre | 空白会被浏览器保留。其行为方式类似 HTML 中的 <pre> 标签。 |
nowrap | 文本不会换行,文本会在在同一行上继续,直到遇到 <br> 标签为止。 |
本例不允许在文本内换行:
</>code
- <html>
- <head>
- <script type="text/javascript">
- function removeWrapping()
- {
document.getElementById("div1").style.whiteSpace="nowrap";
- }
- </script>
- </head>
- <body>
- <div id="div1">
- This is some text. This is some text. This is some text.
- This is some text. This is some text. This is some text.
- This is some text. This is some text. This is some text.
- This is some text. This is some text. This is some text.
- </div>
- <br />
- <input type="button" onclick="removeWrapping()"
- value="Do not let the text wrap" />
- </body>
- </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号