navbar responsiveness with media queries instead of js
This commit is contained in:
parent
2063a32bb9
commit
54a0fa1252
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
init();
|
init();
|
||||||
function init() {
|
function init() {
|
||||||
nav.style.paddingLeft = document.body.getBoundingClientRect().width < 999 ? '90px' : '';
|
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
nav.classList.add('navbar--animated');
|
nav.classList.add('navbar--animated');
|
||||||
}, 200);
|
}, 200);
|
||||||
@ -19,7 +18,7 @@
|
|||||||
// checks scroll direction and shows/hides navbar accordingly
|
// checks scroll direction and shows/hides navbar accordingly
|
||||||
function checkScroll() {
|
function checkScroll() {
|
||||||
var sticky = window.scrollY > 0;
|
var sticky = window.scrollY > 0;
|
||||||
sticky = sticky && window.innerHeight < (document.scrollingElement.scrollHeight - 50);
|
sticky = sticky && window.innerHeight < (document.scrollingElement.scrollHeight - 100);
|
||||||
nav.classList.toggle('navbar--sticky', sticky);
|
nav.classList.toggle('navbar--sticky', sticky);
|
||||||
ticking = false;
|
ticking = false;
|
||||||
}
|
}
|
||||||
@ -32,10 +31,6 @@
|
|||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('resize', function() {
|
|
||||||
nav.style.paddingLeft = document.body.getBoundingClientRect().width < 999 ? '90px' : '';
|
|
||||||
}, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,13 @@
|
|||||||
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 999px) {
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
padding-left: 90px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.navbar__logo {
|
.navbar__logo {
|
||||||
transition: all .2s ease;
|
transition: all .2s ease;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user