Keep div inside view port or arbitrary div on scrolling?

I know this is really old but stumbled across this whilst trying to find my own solution.

I know this is really old but stumbled across this whilst trying to find my own solution This link shows how to do it in a really lightweight fashion. Essentially all you need is the following code (along with jQuery loaded of course) $(function() { var $sidebar = $("#siderbar"), $window = $(window), offset = $sidebar.offset(), topPadding = 15; $window. Scroll(function() { if ($window.scrollTop() > offset.

Top) { $sidebar.stop(). Animate({ marginTop: $window.scrollTop() - offset. Top + topPadding }); } else { $sidebar.stop().

Animate({ marginTop: 0 }); } }); }) If you don't want it to animate simply replace the animation sections like so: $sidebar.stop(). Animate({ marginTop: VALUE }); with $sidebar. Css("marginTop", VALUE).

Oh, thanx, this is still an open issue for me. I've thought of a scroll-event-and-reposition solution, too. But I think it will become more smooth if you change CSS attributes in a way to make the browser stick the element relative to the view port OR relative to the document, this should eliminate flicker/jitter/skew which I've seen with many solutions.

But your code is a good starting point, so +1. – hurikhan77 Feb 4 '11 at 15:12 When I use this to scroll Google Maps inside a DIV I get no flicker or lag! I've noticed borders on elements seem to provide most of the flicker – Chris Feb 4 '11 at 15:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions