Last active
August 18, 2025 12:37
-
-
Save haythamnikolaidis/b42376a2026799d637bea4f56e83322c to your computer and use it in GitHub Desktop.
CSS-only progress bar. No JavaScript needed. Dynamically updates using data attributes.
This file contains hidden or 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
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Javascript-less Progress bar</title> | |
| <style type="text/css" media="all"> | |
| .progress-bar{ | |
| background-color: #c0c0c0; | |
| width: 100%; | |
| height: 2rem; | |
| } | |
| .progress-bar::after{ | |
| display: block; | |
| background-color: green; | |
| height: 2em; | |
| width: calc(attr(data-value type(<number>)) / attr(data-max type(<number>)) * 100%); | |
| content: ''; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="progress-bar" data-value=50 data-max=150></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment