Home  >  Article  >  Web Front-end  >  The white-space attribute of css caused the space problem--looking at the hex, I found that 2020 became c2a0_html/css_WEB-ITnose

The white-space attribute of css caused the space problem--looking at the hex, I found that 2020 became c2a0_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:42:531363browse

Today I discovered a strange problem. I input a piece of text from the text editor (notepad) into the textbox text box (textarea) of easyui. Without any operation, I directly input it from the text box. Copy the text and paste it into the text compiler. By checking the hexadecimal value of the text twice, it is found that the space part has changed. As shown below:


1. Text content 1: (original text is included)


2. Input to easyui In the textbox:


3. Post from the textbox:


Preliminary observation will reveal two pieces of text Changes have occurred on the spaces, further observe its hexadecimal content:

4. Hexadecimal of the original text:


5. Paste The following text hexadecimal:


Obviously, the spaces have changed and been converted into c2a0

passed After half a morning of comparison, I finally found a css attribute: white-space. Check out the w3c explanation:

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

The default is normal, when added to textarea After adding the white-space:pre-wrap attribute, the above problem is easily solved.

Statement:
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