Best practices for CSS non-ASCII characters
Author: zhanhailiang Date:
Problem scenarios
Attribute values of non-ASCII characters are often used when writing styles, as follows:
. Hot_list. sign_discount: before {content: ""; padding: 0 8px; margin-right: 7px; font-size: 12px; line-height: 14px; color: # fff; text-align: center; background-color: # f13993; border-radius: 11px ;}
However, garbled characters may sometimes appear in Chrome:
In addition to content, font fonts are also frequently used for non-ASCII characters, such as font-family: ""
Best practices
To avoid the above Encoding Problems, we recommend that you use backslash escape when non-ASCII characters are involved in CSS to avoid Encoding Problems:
Backslash escapes allow authors to refer to characters they cannot easily put in a document. in this case, the backslash is followed by at most six hexadecimal digits (0 .. 9A .. f), which stand for the ISO 10646 ([iso000046]) character with that number, which must not be zero. (It is undefined in CSS2.1 what happens if a style sheet does contain a character with Unicode codepoint zero .) if a character in the range [0-9a-fA-F] follows the hexadecimal number, the end of the number needs to be made clear.
See http://www.w3.org/TR/CSS2/syndata.html#escaped-characters for details
Therefore, the preceding example can be changed:
.hot_list .sign_discount:before { content: "\6ee1\51cf"; padding: 0 8px; margin-right: 7px; font-size: 12px; line-height: 14px; color: #fff; text-align: center; background-color: #f13993; border-radius: 11px;}