Last active
October 20, 2018 18:02
-
-
Save LeaVerou/9ef99ce3555ba569c24c7532ef37dc9a 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(var(--value) * 100%); | |
background: hsl(calc(var(--value) * 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" style="--value: .02"></div> | |
<div class="progress" style="--value: .1"></div> | |
<div class="progress" style="--value: .3"></div> | |
<div class="progress" style="--value: .5"></div> | |
<div class="progress" style="--value: .7"></div> | |
<div class="progress" style="--value: .9"></div> | |
<div class="progress" style="--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":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment