I have a fixed navigation bar at the top of my website. By default, it is always visible on all pages, but I want to hide it on desktop screens and display it only on mobile devices.
Here is what I have implemented:
@media (min-width: 992px) {
#sp-header-sticky-wrapper {
display: none;
visibility: hidden;
clear: both;
font-size: 0;
max-height: 0;
line-height: 0;
height: 0px !important;
padding: 0;
(optional) mso-hide: all;
(optional)
}
div#sp-header-sticky-wrapper.sticky-wrapper {
display: none;
visibility: hidden;
clear: both;
font-size: 0;
max-height: 0;
line-height: 0;
height: 0px !important;
padding: 0;
(optional) mso-hide: all;
(optional)
}
}
For mobile devices:
@media (max-width: 991px) {
#sp-header-sticky-wrapper {
display: block !important;
visibility: visible;
}
div#sp-header-sticky-wrapper.sticky-wrapper {
display: block !important;
visibility: visible;
}
}
While this setup works well for mobile usage, there's an issue in desktop mode. Whenever I click a link, the hidden navigation bar briefly appears for a fraction of a second before disappearing again. This causes the website to 'jump' slightly when reloading a page.
Is there a solution to this problem? Should I consider using JavaScript, or is that not feasible?