您好,欢迎来到飒榕旅游知识分享网。
搜索
您的当前位置:首页css white-space属性怎么用

css white-space属性怎么用

来源:飒榕旅游知识分享网
css white-space 属性用于设置如何处理元素内的空白,例设置white-space: nowrap,则换行及行首尾空格全部被合并,文本不会换行,文本会在在同一行上继续,直到遇到 <br> 标签为止。

css white-space属性怎么用?

white-space 属性设置如何处理元素内的空白。

这个属性声明建立布局过程中如何处理元素中的空白符。

语法:

white-space : normal | pre | nowrap | pre-wrap | pre-line ;

属性值:

normal:默认。空白会被浏览器忽略。

pre:空白会被浏览器保留。其行为方式类似 HTML 中的 <pre> 标签。

nowrap:文本不会换行,文本会在在同一行上继续,直到遇到 <br> 标签为止。

pre-wrap:保留空白符序列,但是正常地进行换行。

pre-line:合并空白符序列,但是保留换行符。

说明:值 pre-wrap 和 pre-line 是 CSS 2.1 中新增的。

注释:任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。

css white-space属性 示例

<!DOCTYPE html>
<html>

	<head>
	<meta charset="UTF-8">
	</head>

	<head>
	<style type="text/css">
	.box{
	width: 500px;
	border: 1px solid #000;
	margin-bottom:10px ;
	}
	.p1 {
	white-space: nowrap
	}
	</style>
	</head>

	<body>
	<div class="box">
	<p>
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	</p>
	</div>
	<div class="box">
	<p class="p1">
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	Gxlcms
	</p>
	</div>
	
	</body>

</html>

输出:

1.jpg

Copyright © 2019- sarr.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务