
I get a decimal number between 1 to 5 which I want to represent like the above mentioned image. This image for example shows a value 3.7
What will be the best possible way to display it using html + css
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming that you can turn the decimal into a percentage, this is doable with pure CSS. Or, you can use a small snippet of JavaScript to set/adjust the percentage value.
IE7+, Chrome, etc.
Example 1
Simple example, no script, minimal markup: http://jsfiddle.net/GqK6p/6/
HTML
CSS
Example 2
A bit more polished example, allowing for inner styling of each box: http://jsfiddle.net/GqK6p/2/
This also shows the usage of percentage-based width for the bar.
HTML
CSS
Example 3
Here’s an animated variation which shows how to dynamically adjust the width of the progress bar with JavaScript: http://jsfiddle.net/GqK6p/4/
HTML 5 Progress Element
As a side note, the HTML 5
progresselement would probably be the semantic choice for this type of information, but browser support isn’t complete yet, and I don’t think any capability exists to styleprogress.