首页 技术 正文
技术 2022年11月19日
0 收藏 684 点赞 3,507 浏览 912 个字

white-space是CSS的属性,其作用是规定文本不进行换行。

white-space有以下几个值:

1、normal:该值为默认值,段落前后的空白会被浏览器忽略。如下所示:

<div style="width:200px;height:200px;white-space:normal;">    This is an Action!    </div>

我们在This的前面加了许多空白,在Action的后面也加了许多空白。但是结果如下:

每天CSS学习之white-space

2、pre:段落前后的空白会被浏览器保留,文本不会换行。如下所示:

每天CSS学习之white-space

3、nowrap:文本不会换行,直到遇到<br>标签为止。如下所示:

先展示normal的结果:

<div style="width:10px;height:80px;white-space:normal;">    This is an Action!    </div>

结果:

每天CSS学习之white-space

如果换为nowrap,则:

<div style="width:10px;height:80px;white-space:nowrap;">    This is an Action!    </div>

结果:

每天CSS学习之white-space

4、pre-wrap:保留前后空白符,但是会进行正常的换行。如:

<div style="width:10px;height:80px;white-space:pre-wrap;">    Thisisan Action!    </div>

结果:

每天CSS学习之white-space

看到了没?如果段落之间有空格,空格也会换行。

5、pre-line:合并空白序列符,但会保留换行符。什么意思呢?看到上面的pre-wrap的结果了吗?接下来让我们看一看pre-line的结果:

<div style="width:10px;height:80px;white-space:pre-line;">    This is an Action!    </div>

结果:

每天CSS学习之white-space

<div style="width:200px;height:80px;white-space:pre-line;">    This is an Action!    </div>

结果:

每天CSS学习之white-space

pre-line也就是说,将段落前后的空白符去掉,如果在换行的时候有空白符单独一行的,将空白符也去掉。

6、inherit:从父元素继承white-space的属性值。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,943
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,469
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,283
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,098
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,729
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,766