1 // 滚动到顶部固定 2 var navH = $(".fixedTop").offset().top; 3 $(".fixedTop").wrap("<div class=‘background-fixed‘></div>"); 4 $(‘.flowDev‘).scroll(function () { 5 var scroH = $(‘.flowDev‘).scrollTop(); 6 if (scroH >= navH) { 7 $(".fixedTop").css({"position": "fixed", "top": 0}); 8 $(".fixedTop").css({"z-index": "999"}); 9 $(".fixedTop").css({"background": "#f4f4f4"}); 10 $(".fixedTop").css({"width": "94%"}); 11 } else if (scroH < navH) { 12 $(".fixedTop").css({"position": "static"}); 13 $(".fixedTop").css({"background": "#fff"}); 14 $(".fixedTop").css({"width": "100%"}); 15 } 16 });
原文地址:https://www.cnblogs.com/yangguoe/p/9267397.html
时间: 2024-11-05 02:22:57