Search code examples
htmlcssprogress-barprogress

progress element transparent background


i have a <progress> bar and i want to color its track with a linear-gradient. the effect i want to achieve though is having some portions of it to be transparent, so i styled it this way

progress[value]::-webkit-progress-bar {

background-image:
linear-gradient(
to right,
red 33%,
rgba(0,0,0,0) 33%,
rgba(0,0,0,0) 66%,
yellow 66%,
yellow 100%);

}

this renders as a grey bar in the 33% to 66% portion, instead of plain transparent. i've also tried using the value transparent but it does not seem to work. i still get a solid default color.

here is a fiddle: http://jsfiddle.net/0jaysLzu/

is it possible to apply transparency to the track of a progress element?


Solution

  • short answer background-image: should be background:

    long answer You have

    progress[value]::-webkit-progress-bar {
    
    background-image:
    linear-gradient(
    to right,
    red 33%,
    rgba(0,0,0,0) 33%,
    rgba(0,0,0,0) 66%,
    yellow 66%,
    yellow 100%);
    
    }
    

    It should be

    progress[value]::-webkit-progress-bar {
    
    background:
    linear-gradient(
    to right,
    red 33%,
    rgba(0,0,0,0) 33%,
    rgba(0,0,0,0) 66%,
    yellow 66%,
    yellow 100%);
    
    }