目录

white-space

描述 (Description)

white-space属性用于更改用户代理处理元素中的空格。

可能的值 (Possible Values)

  • normal - 元素中的任何空格序列都将转换为单个空格。

  • pre - 元素中的所有空格都被尊重,包括多个空格和回车。

  • nowrap - 元素中的任何空格序列都将转换为单个空格,但禁用自动换行。

适用于 (Applies to)

所有块级元素。

DOM语法 (DOM Syntax)

object.style.whiteSpace = "pre";

例子 (Example)

以下是演示如何处理元素内部空白的示例。

<html>
   <head>
   </head>
   <body>
      <p <b class="notranslate">style = "white-space:pre;"</b>>
         This text has a line break and the white-space pre setting 
         tells the browser to honor it just like the HTML pre tag.
      </p>
   </body>
</html> 

这将产生以下结果 -

新页面打开
↑回到顶部↑
WIKI教程 @2018