Hi all,
Below is an example how to make half color on text using css. In this example we are using custom-attribute.
If you are looking for custom-attribute, In one my previous blog I have explained about it click custom-attribute to know more.
HTML :
<span class="halfStyle" data-content="F">F</span>
<span class="halfStyle" data-content="I">I</span>
<span class="halfStyle" data-content="N">N</span>
<span class="halfStyle" data-content="D">D</span>
<span class="halfStyle" data-content="N">N</span>
<span class="halfStyle" data-content="E">E</span>
<span class="halfStyle" data-content="R">R</span>
<span class="halfStyle" data-content="D">D</span>
CSS :
.halfStyle {
position:relative;
display:inline-block;
font-size:80px;
color: #1086ad;
overflow:hidden;
}
.halfStyle:before {
display:block;
z-index:1;
position:absolute;
top:0;
width: 50%;
content: attr(data-content);
overflow:hidden;
color: #f18b12;
}
Output : The output generated by using above code clearly shows orange on half text and blue color on another half.
F
I
N
D
N
E
R
D
0 Comment(s)