Я создал липкую навигацию, используя следующий jQuery:
jQuery(document).ready(function () {
var top = jQuery('#card').offset().top;
jQuery(window).scroll(function (event) {
var y = jQuery(this).scrollTop();
if (window.matchMedia("(min-width: 700px)").matches) {
if (y >= top)
jQuery('#card').addClass('fixed'),
jQuery('#card').removeClass('fl-row-fixed-width');
else
jQuery('#card').removeClass('fixed'),
jQuery('#card').addClass('fl-row-fixed-width');
jQuery('#card').width(jQuery('#card').parent().width());
}
else {
if (y >= top)
jQuery('#card').addClass('fixed'),
jQuery('#card').removeClass('fl-row-fixed-width'),
jQuery('.fl-node-5bdadb6d18e4a').hide(),
jQuery('.fl-node-5bdadb6d18ec9').hide();
else
jQuery('#card').removeClass('fixed'),
jQuery('#card').addClass('fl-row-fixed-width'),
jQuery('.fl-node-5bdadb6d18e4a').show(),
jQuery('.fl-node-5bdadb6d18ec9').show();
jQuery('#card').width(jQuery('#card').parent().width());
}});
});
и CSS:
.fixed {
position:fixed;
top:0;
z-index:1000;
-webkit-box-shadow: 0 0 30px 0 rgba(0,0,0,.15);
box-shadow: 0 0 30px 0 rgba(0,0,0,.15);
}
Это работает хорошо, однако, когда я прокручиваюсь и прихожу к навигационной панели, которая исправляется, страница переходит ...
Не могли бы вы помочь?