Greetings to all! I am currently working on implementing a progress bar for my website, but I am encountering an issue where the background-color
is not displaying correctly on scroll. I would greatly appreciate any assistance with this matter. Below you can find the code snippets for html
, css
, and jquery
...
HTML Code
<div class="progress-bar-container"><div id="progressbar" value="0"></div></div>
CSS Code
height: 5px;
background-color: #ced4da;
overflow: hidden;
width: 100%;
position: sticky;
position: -webkit-sticky;
top: 48px;
z-index: 440;
}
.progress-bar-container #progressbar {
background-color: #4688f1;
height: 100%;
width: 0;
}
jQuery Code
$(window).scroll(function () {
var s = $(document).scrollTop(),
d = $(document).height() - $(window).height();
$("#progressbar").attr('max', d);
$("#progressbar").attr('value', s);
});
});
If anyone could provide guidance on how to ensure the background color displays correctly on scroll, it would be highly appreciated. Thank you in advance!