【发布时间】:2018-01-17 01:07:18
【问题描述】:
我的网站页面上有一个顶部导航栏,当$(window).scrollTop() > 44 时它实际上得到了修复。这在 Mozilla 上运行良好并且看起来不错,但在 safari 和 chrome 上修复topnavbar 时它会跳跃。有什么解决办法吗?
这是我的代码:-
//js
if(viewportWidth > 1199 && $(window).scrollTop() > 44){
$('#topnavbar').addClass('topnavbarfixed');
}
/*css*/
.topNavBar {
position: relative;
width: 100%;
float: left;
background: #fff;
border-bottom: 1px solid rgba(243, 243, 243, 0.88);
z-index: 999 !important;
padding: 0 !important;
}
.topnavbarfixed {
position: fixed !important;
top: 0;
width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="topnavbar" class="topNavBar">
<!--Logo and some contents here -->
</div>
【问题讨论】:
标签: javascript jquery html css google-chrome