2016-12-28 72 views
4

我通过JavaScript将此类“.sticky”添加到导航栏,但粘滞菜单无法正常工作。固定位置不能在粘性菜单上工作

.sticky { 
position: fixed; 
width: 100%; 
left: 0; 
top: 0; 
z-index: 100; 
border-top: 0; 
-webkit-transform: none; 
transform: none; 
} 

JavaScript代码

//sticky menu 
var stickyNavTop = $('.main-navbar').offset().top; 
var stickyNav = function(){ 
    var scrollTop = $(window).scrollTop(); 

    if (scrollTop > stickyNavTop) { 
     $('.main-navbar').addClass('sticky'); 
    } else { 
     $('.main-navbar').removeClass('sticky'); 
    } 
}; 
stickyNav(); 
$(window).scroll(function() { 
    stickyNav(); 
}); 

能否请您检查页面 http://www.chainreaction.ae/alayam/

谢谢

+0

你能理解这一个的jsfiddle? –

+0

由于某些原因,固定位置不能在网站上工作,如果我为它制作一个JSFiddle。它会工作 – FDI

回答

3

添加这个CSS:

.scotch-panel-canvas { 
    transform: none !important; 
    -ms-transform: none !important; 
    -moz-transform: none !important; 
    -webkit-transform: none !important; 
} 
+0

这会打破画布菜单,还有其他解决方案吗? – FDI

+0

我想要一段时间 –

1

请从scotch-panel-canvas DIV删除内嵌样式然后正常工作......

删除此风格:style="position: relative; height: 100%; width: 100%; transform: translate3d(0px, 0px, 0px); backface-visibility: hidden; transition: all 300ms ease;"

我不知道这个内联css来自哪里,但你应该删除它。我认为这种风格来自一些jQuery。当u删除此代码,它工作正常...

,并增加了z-index