时间:2021-07-01 10:21:17 帮助过:102人阅读
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>
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- </p>
- </div>
- <div class="box">
- <p class="p1">
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- Gxl网
- </p>
- </div>
- </body>
- </html>
输出:
以上就是css white-space属性怎么用的详细内容,更多请关注Gxl网其它相关文章!