[英]How can I stop my sidebar from scrolling when on mobile view?
我有一個在桌面/iPad 視圖上滾動的側邊欄,但它也會在移動視圖上影響它我想在移動視圖/較小屏幕上禁用此 JavaScript 代碼。
var length = $('#filters-sidebar-wrap').height() - $('#filters-sidebar').height() + $('#filters-sidebar-wrap').offset().top;
$(window).scroll(function () {
var scroll = $(this).scrollTop();
var height = $('#filters-sidebar').height() + 'px';
if (scroll < $('#filters-sidebar-wrap').offset().top) {
$('#filters-sidebar').css({
'position': 'absolute',
'top': '40px',
'width': '290px'
});
} else if (scroll > length ) {
$('#filters-sidebar').css({
'position': 'absolute',
'bottom': '0',
'top': 'auto',
'width': '290px'
});
} else {
$('#filters-sidebar').css({
'position': 'fixed',
'top': '128px',
'width': '290px',
'height': 'height'
});
}
});
我能夠解決我的問題,謝謝大家的幫助!
if(window.innerWidth < 992 ) {
$("#filters-sidebar").removeAttr("style");
} else {
/// Add code here
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.