How to make this effect in the text inside the progress bar where the text changes color according to the fill of the bar, and when the bar reaches the text, only a part of the text changes color?
Noticethatwhenyou'rein50%halfthetextcolorturnswhiteincontrasttotheblackbackgroundandtheotherhalfblackincontrasttothewhitebackground.Whenthebackgroundbelowthetextiswhite,thetextiscompletelyblackandviceversa.
HowtodothisusingCSSandJavaScripttobargofrom0%to100%inacertaintimeperiod,sayin10seconds?
Thebarcodewouldbethisbelow,butitcanbechangedatwillsothatthedesiredeffectcanbeachieved:
#barra{
display: block;
width: 298px;
height: 28px;
line-height: 28px;
text-align: center;
color: #000;
border: 1px solid #000;
position: relative;
}
#progresso{
display: block;
width: 15%;
height: 100%;
background: #000;
position: absolute;
top: 0;
left: 0;
}
<div id="barra">
<div id="progresso">
</div>
<strong>15%</strong>
</div>