Skip to content

Instantly share code, notes, and snippets.

@minaguib
Last active July 15, 2023 18:52
Show Gist options
  • Save minaguib/83e09e00bbfe7bec1d90870e6e3af51e to your computer and use it in GitHub Desktop.
Save minaguib/83e09e00bbfe7bec1d90870e6e3af51e to your computer and use it in GitHub Desktop.
Single-DIV CSS progress bar

CSS:

        div {
            position: fixed;
            right: 0;
            background: #ff83c2 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+M/Q/B8ABgYCgg7mTRwAAAAASUVORK5CYII=) no-repeat;
            padding: 1em;
            font: 2em monospace;
            color: white;
            border: 2px solid white;
            z-index: 100;
            opacity: 80%;
        }

Then to adjust actual progress:

div.style.backgroundSize = ((elapsed / total)*100) + "% 100%";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment