-
-
Save halfninja/73d79c84a5f63369aab081166284fd60 to your computer and use it in GitHub Desktop.
Progress bar that changes width AND color using a CSS variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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%); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alert('Hello world!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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