css white-space属性怎么用

互联网 19-5-27
css white-space 属性用于设置如何处理元素内的空白,例设置white-space: nowrap,则换行及行首尾空格全部被合并,文本不会换行,文本会在在同一行上继续,直到遇到 标签为止。

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> 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 			</p> 		</div> 		<div class="box"> 			<p class="p1"> 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 				php中文网 			</p> 		</div> 		 	</body>  </html>

输出:

以上就是css white-space属性怎么用的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:css transform-origin属性怎么用

相关资讯