Check out my CSS and HTML code here: https://jsfiddle.net/z2cc11yk/
Here's the HTML:
<div class="progressbar-container">
<div class="progressbar-text">125%</div>
<div class="progressbar-progress" style="background-color: red; width: 100%; transition: width 200ms ease 0s; height: 20px;"></div>
</div>
<div class="progressbar-container">
<div class="progressbar-text">50%</div>
<div class="progressbar-progress" style="background-color: rgb(11, 211, 24); width: 50%; transition: width 200ms ease 0s; height: 20px;"></div>
</div>
And this is the CSS code:
.progressbar-progress{
background-color: rgb(11, 211, 24);
width: inherit;
transition: width 200ms ease 0s;
height: 100%;
position:absolute;
margin:0 10;
z-index: -2;
}
.progressbar-text{
width: 100%;
height: 100%;
position:absolute;
z-index: -1;
}
.progressbar-container{
border-style: solid;
height: 20px;
border-width:1px;
text-align:center;
width: 100%;
}
I'm facing an issue with the absolute positioning of child elements inside the progress bar container. The child element becomes larger than the parent when it's filled to 100%. How can I constrain it within the progressbar-container?
Also, why does the height fill up even when the children element's width exceeds the parent element?