Skip to content

Instantly share code, notes, and snippets.

@halfninja
Forked from LeaVerou/dabblet.css
Created October 20, 2018 18:02
Show Gist options
  • Save halfninja/73d79c84a5f63369aab081166284fd60 to your computer and use it in GitHub Desktop.
Save halfninja/73d79c84a5f63369aab081166284fd60 to your computer and use it in GitHub Desktop.
Progress bar that changes width AND color using a CSS variable
/**
* Progress bar that changes width AND color using a CSS variable
*/
div {
display: flex;
height: .8em;
margin: 1em 0;
background: hsl(220,10%,80%);
}
div::before {
content: "";
width: calc(attr(data-value number) * 100%);
background: hsl(calc(attr(data-value number) * 90), 50%, 50%);
}
<div class="progress" data-value=".02"></div>
<div class="progress" data-value=".1"></div>
<div class="progress" data-value=".3"></div>
<div class="progress" data-value=".5"></div>
<div class="progress" data-value=".7"></div>
<div class="progress" data-value=".9"></div>
<div class="progress" data-value="1"></div>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"","page":"javascript"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment