css - Style HTML5 progress tag that reached it's maximum value -


is possible style progressbar reached max-value differently in css 1 hasn't started yet or started?

for example doing like

progress[max=value] { background: green // color when maxed out } progress { background: red;//default color } 

or have use javascript detect it?

this answer assumes know maximum value of progress bar. i'm going use following markup:

<progress max=100 value=100></progress> 

our progress bar here has maximum value of 100 , value of 100, meaning @ completed state. can use [att=val] selector target @ completed state:

progress[value="100"] { ... } 

chris coyier has article on css tricks explains how progress element can styled in chrome, firefox , ie10. following can apply styling completed progress bar. first reset style:

progress[value="100"] {     -webkit-appearance: none;     -moz-appearance: none;     appearance: none; } 

then can apply styling ::-webkit-progress-value , ::-moz-progress-bar target foreground progress bar on both chrome , firefox. i'm setting background colour of #f00 (red):

/* chrome */ progress[value="100"]::-webkit-progress-value {     background:#f00; }  /* firefox */ progress[value="100"]::-moz-progress-bar {     background:#f00; } 

finally can add in ie10 styling adding color property on main selector:

progress[value="100"] {     -webkit-appearance: none;     -moz-appearance: none;     appearance: none;      /* ie10 */     color:#f00; } 

here jsfiddle demo demonstrating 2 progress bars - first @ 50% , second @ 100%. lazy, here result across chrome, firefox , ie10:

chrome, firefox , ie10 progress bar result


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -