If you have a website page that’s on the longer side, it can be helpful to show viewers where they are in their scroll! The simplest way to do this: display a progress bar. It adds visual interest to your site, and it gives readers an important reference point as they move below the fold. With Duda, this is an easy addition — the
Dear America Foundation created one that highlights their brand colors. Today, we’re here to show you how to show page scroll progress on your site. Follow the instructions below to implement this Duda tip on your site, or check out this video to watch each step in real time!
On your Duda website, select your header and click “Set as sticky header.” This setting must be turned on for your progress bar to show up!
After you’ve created a sticky header, select "Edit Design.” This will open a menu box.
In the design menu, navigate to “Spacing” on the far right. From here, change your default padding to zero for both top and bottom.
After your padding settings have been saved, open Developer Mode and find the section labeled “Header/Footer.” In that menu select header.html.
In the header.html menu, paste the custom code below right after the first line of code:
<div class="progress-container">
<div class="progress-bar" id="myBar">
</div>
</div>
It should look like this:
While still in Developer Mode, revisit the main menu and find Site HTML/CSS. It’s just below the Header/Footer options. From there, select site.css.
It’s time to add the second part of the progress bar code to the bottom of your editor. Paste the following custom code into your site:
.progress-container {
width: 100%;
height: 8px;
background: #bf0b30; /* color of the container - #bf0b30 is red */
}
.progress-bar {
height: 8px;
background: #002768; /* color of the progress bar - #002768 is blue */
width: 0%; /* width is set to zero as the initial state and will be overridden by javascript */
}
.prog{
left:0 !important;
top:0 !important ;
transition: all ease 0.3s;
}
It should look like this:
To change the color of your progress bar, you'll need to edit the hex color code under the background property above for both the progress container and the progress bar itself. You can use an external tool, like HTML Color Codes, to pick a color you like if you don't already have branded hex color codes in mind. Once your colors are selected, save the code and go back to the HTML/CSS menu.
In the HTML/CSS menu, select body-end.html – it’s located right above site.css.
It’s the final coding step! Paste the following custom code into your site:
<script>
window.onscroll = function() {myFunction()};
function myFunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("myBar").style.width = scrolled + "%";
}
</script>
It should look like this:
There you have it! A progress bar with custom colors, there to show visitors how far along they are on your page. Here’s the final result from our Dear America Foundation project:
Get new resources to your inbox.
We'll send our latest agency resources including the Duda Tip of the Week and more straight to your inbox.
CASE STUDIES
When James with Restoration Growth Partners came to us, he was building all of his agency's websites himself. Since...
Before working with us, Zambuki was stitching together different contractors to fulfill their web projects. Now they...
We really do mean it when we say "become a partner." Let us become an extension of your agency so you can focus on what matters most, your clients.
Zoom Agency. All Rights Reserved.
NEW