让一个div始终固定在页面的某一固定位置的方法

方法一:直接用position:fixed

方法二:写一个滚动条滚动事件,让这个div设置 position:absolute 该top的距离等于滚动的距离scrollTop()

写法如下:$(window).scroll(function(){
                   var tops = $(this).scrollTop();
                  $('.Return_header').css({'top':tops})
            })

原文地址:https://www.cnblogs.com/dearxinli/p/4050386.html