0
I made a page in bootstrap and also a smooth scroll, but this scroll is not of the page but of a div.
The main scroll of the page I took, and the page itself is inside that div.
Is there any way I can leave the div scroll as main? As soon as they enter the page they need to click to scroll down the bar.
And I also need to change one class
once I scrolled the page from a certain value, but it doesn’t change because in my code it takes the scroll from the body, but I wanted it to take the scrol from the div.
Follow my code below:
window.onscroll = function() {myFunction()};
var header = document.getElementById("banner");
var sticky = header.offsetTop;
function myFunction() {
if (window.pageYOffset > sticky) {
header.classList.add("sticky-top");
} else {
header.classList.remove("fixed-bottom");
}
}
<div class="main">
a pagina em si esta aqui junto com scroll
</div>
Dude you want the menu to stay fixed when scrolling the page ?
– hugocsl
more because you need to use the scroll of the div being that can customize the scroll of the browser? alias, the right one was for you to do this scroll in the <body> tag for hierarchy.
– Macedo_Montalvão
Good night, you guys. So it’s because I need the smoth scroll property and it just works that way, in the body tag I already tried and it didn’t work. The main reason was more for this and because of the smoth separate it by Section
– Sou um lixo em programação
Hugo na vdd, I want as soon as I enter the page the navbar stay below and as soon as I roll the page I came up
– Sou um lixo em programação