The CSS content property is extremely useful. Using it, for example, you can put a comma after each element of the list: li:after { content: ','; }li:after { content: ','; }
Sometimes it is necessary to set the value of this property in the form of the UNICODE character set (in order not to care about the compatibility of encodings, or if the value contains a line break). The question is how to get the UNICODE character set from a string?
I suggest taking advantage of Javascript. ')
So, for one character, type in the address bar of the browser (replace the "," with the symbol you need):
javascript:alert( '\\' + new String( ',' ).charCodeAt(0).toString(16))
* This source code was highlighted with Source Code Highlighter .
The result can be transferred to the value of the content property: li:after { content: '\2c'; }li:after { content: '\2c'; }
If the string is long and you are too lazy to type, then use the code below:
String.prototype.toCSSHex = function () { var text = this .toString();
var result = '' ; var separator = '\\' ;
for ( var currentIndex = 0, length = text.length; currentIndex < length; currentIndex++) { result += separator + text.charCodeAt(currentIndex).toString(16); }
return result; }
var test = ', !' ; alert(test.toCSSHex()) ;
* This source code was highlighted with Source Code Highlighter .