How do I get a fixed position div to scroll horizontally with the content? Using jQuery
问题 I have a div.scroll_fixed with the following CSS .scroll_fixed { position:absolute top:210px } .scroll_fixed.fixed { position:fixed; top:0; } I'm using the following jQuery code to set the .fixed class when the div reaches the top of the page. var top = $('.scroll_fixed').offset().top - parseFloat($('.scroll_fixed').css('margin-top').replace(/auto/, 0)); $(window).scroll(function (event) { // what the y position of the scroll is var y = $(this).scrollTop(); // whether that's below the form if