Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8762201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:28:04+00:00 2026-06-13T15:28:04+00:00

I get a decimal number between 1 to 5 which I want to represent

  • 0

show values as colored representation

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:28:05+00:00Added an answer on June 13, 2026 at 3:28 pm

    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.

    enter image description here

    IE7+, Chrome, etc.

    Example 1

    Simple example, no script, minimal markup: http://jsfiddle.net/GqK6p/6/

    HTML

    <div id="progress"></div>
    <ul id="mask">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
    

    CSS

    #wrapper { position: relative; height: 30px; width: 180px; }
    #progress { position: absolute; top: 0; left: 0; z-index: 0; background-color: red; width: 74%; height: 100%; }
    #mask { position: absolute; z-index: 1; height: 100%; }
    LI { float: left; border: 4px solid #aaa; height: 22px; width: 22px; }
    

    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

    <div id="wrapper">
        <div id="progress"></div>
        <ul id="mask">
            <li><div></div></li>
            <li><div></div></li>
            <li><div></div></li>
            <li><div></div></li>
            <li><div></div></li>
            <li><div></div></li>
        </ul>  
    </div>
    

    CSS

    #wrapper { position: relative; height: 30px; width: 180px; }
    
    /* set width to whatever percentage makes sense based on decimal value */
    
    #progress { position: absolute; top: 0; left: 0; z-index: 0; background-color: red; 
        width: 59%; height: 100%; }
    
    #mask { position: absolute; z-index: 1; height: 100%; }
    LI { float: left; border: 4px solid #aaa; height: 22px; width: 22px; }
    LI > DIV { border: 1px solid #555; height: 20px; }
    

    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/

    var progress = $("#progress");
    var width = 0; // use whatever starting value makes sense
    
    setInterval(function(){
    
        // increment/process as desired
        if( ++width > 100 ){
             width = 0;
        }        
    
        progress.css("width",  width + "%");       
    }, 25);​
    

    HTML 5 Progress Element

    As a side note, the HTML 5 progress element 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 style progress.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this public class AViewModel { public decimal number { get;
I need to get the decimal part out of a float number, for example:
How to get decimal point of a number? For example: If I have 1.5
I know there are ways to get the number of digits after a decimal
In a UITextField used for entering decimal numbers I would like to get rid
I am trying to get decimal value using LINQ in a MVC3 project. How
I need to get the left hand side integer value from a decimal or
can i get validation on weight which can take decimal values and also integer.
This is about how to do number conversion between binary to octal, octal to
I have a float and I am trying to get a random number between

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.