{"id":82,"date":"2010-12-14T20:45:20","date_gmt":"2010-12-14T20:45:20","guid":{"rendered":"http:\/\/brucemyers.com\/?p=82"},"modified":"2020-09-15T14:40:52","modified_gmt":"2020-09-15T14:40:52","slug":"css-progress-bar-or-gauge","status":"publish","type":"post","link":"https:\/\/brucemyers.com\/?p=82","title":{"rendered":"CSS Progress Bar or Gauge"},"content":{"rendered":"<p>Today I needed a gauge to show where on a scale that a value fell.<\/p>\n<p>Example:<br \/>\n<a href=\"http:\/\/brucemyers.com\/wp-content\/uploads\/2010\/12\/progressbar.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/brucemyers.com\/wp-content\/uploads\/2010\/12\/progressbar-300x19.png\" alt=\"progressbar\" class=\"alignnone size-medium wp-image-89\" width=\"300\" height=\"19\" srcset=\"https:\/\/brucemyers.com\/wp-content\/uploads\/2010\/12\/progressbar-300x19.png 300w, https:\/\/brucemyers.com\/wp-content\/uploads\/2010\/12\/progressbar.png 438w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I wanted to use CSS instead of dynamically creating an image in PHP or creating 100 static images.<\/p>\n<p>I found some samples that use DIV tags to create a gauge, but I needed to put text both before and after the gauge on the same line.<br \/>\nSo I modified the sample <a href=\"http:\/\/blog.leetsoft.com\/2006\/8\/22\/super-simple-css-bars\">Super simple CSS bars<\/a>.<br \/>\n<!--more--><\/p>\n<h3>CSS<\/h3>\n<p><code>.progresslineleft {<br \/>\nclear: left;<br \/>\nfloat: left;<br \/>\npadding-top: 4px;<br \/>\n}<\/code><\/p>\n<p><code>.progresslineright {<br \/>\nfloat: left;<br \/>\npadding-top: 4px;<br \/>\n}<\/p>\n<p>.progressbar {<br \/>\nborder: 1px solid #ccc;<br \/>\nwidth: 100px;<br \/>\nmargin: 2px;<br \/>\npadding: 1px;<br \/>\nbackground: white;<br \/>\nfloat: left;<br \/>\n}<\/p>\n<p><\/code><code>.progressbar div {<br \/>\nbackground-color: #ACE97C;<br \/>\ntext-align: right;<br \/>\n}<\/code><\/p>\n<h3>HTML<\/h3>\n<p><code>&lt;div class=\"progresslineleft\"&gt;Uniqueness Score: Similiar (0)&amp;nbsp;&lt;\/div&gt;<br \/>\n&lt;div class=\"progressbar\"&gt;&lt;div style=\"width:44%\"&gt;44&lt;\/div&gt;&lt;\/div&gt;<br \/>\n&lt;div class=\"progresslineright\"&gt;&amp;nbsp;Unique (100)&lt;\/div&gt;<\/code><\/p>\n<p>Change the 44's to the value that should be displayed in the gauge.<\/p>\n<h3>Discussion<\/h3>\n<p>SPAN tags won't work because they can't have a width attribute. Plain DIV tags won't work because each DIV starts on a new line.<\/p>\n<p>The solution is to float the DIVs.<\/p>\n<p>This has been tested with Firefox 3, Safari 5 and IE 8.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I needed a gauge to show where on a scale that a value fell. Example: I wanted to use CSS instead of dynamically creating an image in PHP or creating 100 static images. I found some samples that use DIV tags to create a gauge, but I needed to put text both before and &hellip; <a href=\"https:\/\/brucemyers.com\/?p=82\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">CSS Progress Bar or Gauge<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[37],"class_list":["post-82","post","type-post","status-publish","format-standard","hentry","category-css","tag-css"],"_links":{"self":[{"href":"https:\/\/brucemyers.com\/index.php?rest_route=\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brucemyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brucemyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brucemyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brucemyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=82"}],"version-history":[{"count":9,"href":"https:\/\/brucemyers.com\/index.php?rest_route=\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":200,"href":"https:\/\/brucemyers.com\/index.php?rest_route=\/wp\/v2\/posts\/82\/revisions\/200"}],"wp:attachment":[{"href":"https:\/\/brucemyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brucemyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brucemyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}