Page Scroll Progress Bar is a progress bar displayed anywhere on your website that indicates how much page is scrolled.
Generally, the page scroll progress bar is located at the top of your website and it indicates the amount of page you have scrolled.
Today you will find page scroll progress bar on many websites. Especially on websites which are hosted on WordPress and some websites which are hosted on blogger.
Most of the blogger template designers add this progress bar by default in the template. But if you don't have that progress bar in your template then you can add it manually.
If you notice then you will see that I am also using scroll progress bar indication on this website. Have a look at the top of this webpage.
This page scroll progress bar is fixed at the top of your web page.
To add this page scroll progress bar in blogger follow the steps which are provided below.
In simple words let's break down the code I have provided you.
Then I used gradients as the background colour and the gradient fill amount and for that, I have to use the CSS variable called var(--scroll) because the variable will be updated automatically each time when we scroll our web page.
In the JavaScript code simply have to get the scrolled page value by scroll event using.
Then we have to set that page scroll value to CSS variable using.
That's all about the page scroll progress bar indicator it seems pretty cool.
Generally, the page scroll progress bar is located at the top of your website and it indicates the amount of page you have scrolled.
Today you will find page scroll progress bar on many websites. Especially on websites which are hosted on WordPress and some websites which are hosted on blogger.
Most of the blogger template designers add this progress bar by default in the template. But if you don't have that progress bar in your template then you can add it manually.
If you notice then you will see that I am also using scroll progress bar indication on this website. Have a look at the top of this webpage.
This page scroll progress bar is fixed at the top of your web page.
To add this page scroll progress bar in blogger follow the steps which are provided below.
Steps to add page scroll progress bar in blogger:
- Go to Blogger Dashboard
- Go to Theme/Template Section
- Click Edit HTML
- Now Search for </body>
- Now copy the code provided below and add it above the tag which we have founded in step 4.
- Save Theme/Template
To search anything in blogger template section press Ctrl+F and then type term to search and press enter.
<div class="progress"></div>
<style>
.progress {
background: linear-gradient(to right, #fc801c var(--scroll), transparent 0);
background-repeat: no-repeat;
position: fixed;
top:0;
left:0;
width: 100%;
height: 4px;
z-index: 1;
animation:background .5s;
}
</style>
<script>
var h = document.documentElement,
b = document.body,
st = 'scrollTop',
sh = 'scrollHeight',
progress = document.querySelector('.progress'),
scroll;
document.addEventListener('scroll', function() {
scroll = (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100;
progress.style.setProperty('--scroll', scroll + '%');
}, {
passive: true
});
</script>
In simple words let's break down the code I have provided you.
Code Analysis:
In the CSS code I have used position:fixed;top:0; to fix this page scroll progress bar indicator at the top of the web page.Then I used gradients as the background colour and the gradient fill amount and for that, I have to use the CSS variable called var(--scroll) because the variable will be updated automatically each time when we scroll our web page.
In the JavaScript code simply have to get the scrolled page value by scroll event using.
scroll = (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100;
Then we have to set that page scroll value to CSS variable using.
progress.style.setProperty('--scroll', scroll + '%');
That's all about the page scroll progress bar indicator it seems pretty cool.