let navbar = document.getElementById('navbar');
let mainpos = document.getElementById('main');
let navPos = mainpos.getBoundingClientRect().top;
window.addEventListener('scroll', e => {
let scrollPos = window.scrollY;
if (scrollPos > navPos) {
navbar.classList.add('sticky');
} else {
navbar.classList.remove('sticky');
}
});