, , CSS. BeatAlex, script, . , 2 , , BeatAlex - - . . , overflow:hidden
, , . script ( ). , ( ), span
, span. , , / , , , . :
CSS
.distinct-accent {
font-size:30px;
color:blue;
}
.with-accent {
position:relative;
display:inline-block;
}
.with-accent:before {
content:attr(data-content);
position:absolute;
left:0;
top:0;
height:0.4em;
width:100%;
padding-right:0.1em;
color:red;
overflow:hidden;
}
JS
$(".distinct-accent").html(function(i, oldhtml){
var newhtml = "";
for(var i = 0; i < oldhtml.length; i++){
var nextChar = "";
var code = oldhtml.charCodeAt(i);
if((code > 64 && code < 90) ||
(code > 96 && code < 123) || code == 32) nextChar = oldhtml[i];
else {
nextChar = "<span class='with-accent' data-content='" + oldhtml[i] + "'>" + oldhtml[i] + "</span>";
}
newhtml += nextChar;
}
return newhtml;
});
:
. webkit (, Chrome), (content:attr
innerHtml
). - ( ) Chrome, . , HTML ).
, ( , CSS ). .
script:
.each(function(){
$(this).replaceWith($(this).clone(true));
});