Code: [ Select all ]
document.addEventListener("DOMContentLoaded", function(){
window.addEventListener('scroll', function() {
if (window.scrollY > 50) {
document.getElementById('navbar_top').classList.add('fixed-top');
navbar_height = document.querySelector('.navbar').offsetHeight;
document.body.style.paddingTop = navbar_height + 'px';
} else {
document.getElementById('navbar_top').classList.remove('fixed-top');
document.body.style.paddingTop = '0';
}
});
});
Code: [ Select all ]
.fixed-top {
top: -40px;
transform: translateY(40px);
transition: transform 1s;
background-image: linear-gradient(to bottom, #292d30, #25282c, #212428, #1e1f23, #1a1b1f);
border-bottom: 2px inset #111;
}