I am trying to write a telugu text using uni codes so that I can highlight the text by changing into multiple colours according to sound. for that I am using html5 and js
<div class="pa">ప</div>
<div class="paa">పా</div>
by using
$("#paa").animate({ color: "blue" }, 500);
I can change the entire colour of the letter but now I want to highlight some part of that letter . Please suggest how it can be done.???
there is a few css tricks to fake the background-clip:text; or something alike SVG.
span {
position:relative;
color:green;
}
span:before {
position:absolute;
top:0;
left:0;
overflow:hidden;
content:attr(data-text);
color:blue;
height:0.7em;
overflow:hidden;
animation: txtclr 4s infinite;
}
p {
background:yellow;
color:rgba(128, 0, 128 , 0.5);
font-size:2em;
font-weight:bold;
background:linear-gradient(to bottom,lightgray 50%,yellow 50%);
display:table;/* demo purpose to shrink to text size*/
box-shadow:inset -3em 0 rgba(100,100,100,0.5);
}
@keyframes txtclr {
0% {
height:50%;
}
25%,75%{
height:0;
width:0;
}
50%{
height:100%;
}
}
<p><span data-text="my text">my text</span> and some other text </p>
run code snippet and see green text filling with blue from top to bottom.
no prefix added, later browser do not need it :)
It is feasible, but not easy with all languages. In the following example, I colored accents on certain letters. http://jsfiddle.net/07hh3z2n/5/
The hint is to use a CSS to get an inline-block
with no width.
.phantom {
display: inline-block;
color: red;
width: 0;
overflow: visible;
}
If the part of the letter you want to highlight is an existing unicode char, this will work fine. Otherwise, you can try to use (or create) a special font with the parts of letters to highlight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With