0
我在我的網站頁面上有一個topnavbar,實際上在$(window).scrollTop() > 44
時得到固定。這工作正常,在Mozilla上看起來不錯,但在修復topnavbar
時Safari和Chrome跳躍。任何解決方案topnavbar堅持不適用於Chrome和Safary,但在mozilla上工作
這是我的代碼: -
//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>