css的white-space属性导致了空格问题--查看十六进制发现2020变成了c2a0_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:42:53
Original
1312 people have browsed it

            今天发现了一个奇怪的问题,从文本编辑器(notepad++)中把一段文本输入到easyui的textbox文本框(textarea)中,不进行任何的操作,直接再从文本框中把文本拷贝出来贴到文本编译器中,通过查看两次文本的十六进制,发现空格部分发生了变化。如下图:


1、文本内容1:(原始文本被容)


2、输入到easyui的textbox中:


3、从文本框中产贴出来:


初步观察会发现两段文本在空格上发生了变化,进一步观察其十六进制内容:

4、原始文本的十六进制:


5、粘贴后的文本十六进制:


很明显,空格发生了变化,被转成了c2a0

经过了半上午的对比,最终发现了一个css属性: white-space,查看w3c解释:

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

默认是normal,当在textarea中加上white-space:pre-wrap 属性以后,上述问题迎刃而解。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!