CSS white-space 属性 | CSS 文本格式 | CSS教程

返回到:CSS 文本格式 | CSS教程

属性定义及使用说明

white-space属性指定元素内的空白怎样处理。

默认值:normal
继承:yes
版本:CSS1
JavaScript 语法:object.style.whiteSpace=”pre”

属性值

描述
normal默认。空白会被浏览器忽略。
pre空白会被浏览器保留。其行为方式类似 HTML 中的 <pre> 标签。
nowrap文本不会换行,文本会在在同一行上继续,直到遇到 <br> 标签为止。
pre-wrap保留空白符序列,但是正常地进行换行。
pre-line合并空白符序列,但是保留换行符。
inherit规定应该从父元素继承 white-space 属性的值。

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号。

紧跟在 -webkit-, -ms- 或 -moz- 前的数字为支持该前缀属性的第一个浏览器版本号。

属性谷歌IE火狐苹果opera
white-space 1.03.01.01.03.5

实例

规定段落中的文本不进行换行:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Web176教程(web176.com)</title> 
<style>
p
{
	white-space:nowrap;
}
</style>
</head>
<body>

<p>
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.
</p>

</body>
</html>

作者:terry,如若转载,请注明出处:https://www.web176.com/cssprop/5746.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2022年4月22日 下午2:23
下一篇 2022年4月22日 下午2:28

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注