移动端常见menu移动置顶

//站位层 初始高度0
//menu $(document).ready(function() { var $window = $(window); var brandName = $('#brandName') var brandNameAnchor = $('#brandNameAnchor'); $window.scroll(function() { var window_top = $window.scrollTop(); var div_top = brandNameAnchor.offset().top; if (window_top > div_top) { brandName.addClass('stick'); brandNameAnchor.height(brandName.height()); //menu悬浮后 站位层高度等于menu层高度顶替原位置 } else { brandName.removeClass('stick'); brandNameAnchor.height(0); } }); });

你可能感兴趣的:(移动端常见menu移动置顶)