Create a Stylish Top Header Scroll Progress Bar for Your Blog: A Step-by-Step Guide



Introduction:

As user experience is becoming more and more important in the fast paced digital world of today, one must be very cautious to offer better browsing without any issues.

 Aside from being a modern element that you could add up, the scroll progress bar also improves user experience and provides users feedback on their read progression.

 Here in this blog, we will guide you on how to Create Custom Scroll Progress Bar On Webpage Top Header Using HTML CSS & JavaScript. You can use it on Blogger or any other content based site.

Before continuing this tutorial, it's a good idea to make a backup of the blogger theme first. So that if something goes wrong during installation, we can easily restore it. 

Table of Contents:

  1. Introduction to Scroll Progress Bars
  2. Why Use a Top Header Scroll Progress Bar?
  3. Setting Up Your Project
  4. HTML Structure for the Progress Bar
  5. Styling the Progress Bar with CSS
  6. Adding Scroll Functionality with JavaScript
  7. Customizing the Progress Bar for Your Blog
  8. Testing and Debugging
  9. Final Thoughts and Best Practices
  10. Conclusion

1. Scroll-progress-bars Introduction

Scroll progress bars are visual indicators that inform visitors how much of the page they have scrolled. They are especially good for long-form content, as the reader can lose their spot on a page quickly.

2. What a top header Scroll Progress Bar?

There are some advantages on the dynamics part, with adding a scroll progress bar at the top of your page not only enhances functionality but also visually,is aesthetically good. A top header scroll progress bar is a better choice for your website instead of the classic scrollbar to right and can help retain your readers. 

This allows it to give immediate feedback on what styles of reading strategies help a student, which in turn gives them motivation to keep going!

3. Setting Up Your Project

The first thing to do is: set Up your test case and then, enjoy reading the code 

Before we dive into the code, make sure you have the following setup:

  • A basic add html code (index.html)
  • A Add CSS code (styles.css)
  • A add JavaScript code (script.js)

This tutorial assumes that you’re familiar with the basics of HTML, CSS, and JavaScript.

4. Structure of the progress bar in HTML

To save the files, we need to define an HTML structure. We're going to have two divs, one for the container and another one where we will include our progres bar.

Copy tha html code and go to your blogger dashboard and click on theme and open a new window then click on arrow icon then click on edit html 

Prass your keyboard ctrl+ f And find a opening <body> tag and past it tha next  html code


<div id="isProgressBefor">
</div>
<div id="isProgressBarrogressBar"></div>

5. Styling the Progress Bar with CSS

We will then use CSS to style these elements. The container will be positioned fixed at the top of the page and we want a progress bar to adjust depending on current scroll.

Then press your keyboard ctrl+f and find closings </b:skin> tag then past the css code  before closing </b:skin> tag 


#isProgressBefor{
  display: block;
  position:fixed;
  top:0;
  left: 0;
  right: 0;
  height: 5px;
  z-index: 1000;
  background-color: white;
  box-shadow: 3px 4px 5px 0px rgba(204 185 185 / .75);
  }

#isProgressBarrogressBar{
  background: linear-gradient(90deg, rgba(17, 48, 201, 1) 30%, rgba(8, 49, 255, 1) 50%, rgba(167, 0, 255, 1) 80%, rgba(174, 8, 255, 1) 100%);
  position:fixed;
  height: 5px;
  border-radius: 2px;
  top:0;
  left:0;
  z-index:1000;
  width:0%;
}

6. Adding Scroll Functionality with JavaScript

Our work almost complete next copy tha next javascript code and go to your end code closing </body> tag and past it before closing </body> tag


<script>//<![CDATA[
window.addEventListener("scroll", () => {
    const winScroll = document.body.scrollTop || document.documentElement.scrollTop;
    const height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
    const scrolled = (winScroll / height) * 100;
    document.getElementById("isProgressBarrogressBar").style.width = `${scrolled}%`;
});
//]]></script>
If this doesn't work in desktop mode to past the css code 


<style>
#isProgressBefor{
  display: block;
  position:fixed;
  top:0;
  left: 0;
  right: 0;
  height: 5px;
  z-index: 1000;
  background-color: white;
  box-shadow: 3px 4px 5px 0px rgba(204 185 185 / .75);
  }

#isProgressBarrogressBar{
  background: linear-gradient(90deg, rgba(17, 48, 201, 1) 30%, rgba(8, 49, 255, 1) 50%, rgba(167, 0, 255, 1) 80%, rgba(174, 8, 255, 1) 100%);
  position:fixed;
  height: 5px;
  border-radius: 2px;
  top:0;
  left:0;
  z-index:1000;
  width:0%;
}
</style>

7. How to customize the Progress Bar for your Blog

You may also customize the progress bar to make it look like your blog. This might include:

Modify the Colors: Replace gradient colors with those reflecting your site color palette.

Change the Height- Increase or decrease the height of the progress bar.

Changing the Position: Rather than putting it at the top, you may want to move it down or make it bigger for a stronger impact.

8. Testing and Debugging

When you put your code, then test the progress bar on multiple devices and screen sizes to check it is running correctly. Pay attention to:

Tests  Put them on Chrome, Firefox, Safari and Edge.

You need to check how the progress bar works on mobile device.

Performance: do not make the scroll event handler cost you your page speed.

9. Summary of lorem ipsum dolor

Your most important scroll progress bar tips

Minimize the Performance Impact: Make minimal, efficient use of JavaScript so it does not significantly slow down performance.

Suggestion from User Feedback: Try to include user feedback mechanisms (e.g. indicate the percentage scrolled).

Accessibility Make sure that this progress bar does not impact the accessibility of your site.

10. Conclusion

One of the easiest and most enduring value additions that you can make to your blog is by including a scroll progress bar. In a few lines of HTML, CSS and Javascript you can make a feature which not only looks good but also provides utility to your users.

In this article, you have leaned how to create and style a scroll progress bar in the top header of your page. Play with styles and features to create a unique version for yourself. Happy coding!

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.