What is the best way to change an element's CSS position to fixed without losing the current scroll position?
Here is a method using JavaScript:
$('.bigwidth').click(function() {
$(this).css('position','fixed');
})
For example, visit this link: http://jsfiddle.net/7gRZJ
If you try scrolling the element and then clicking on it, it will change to a fixed position and reset the scroll. This behavior can be improved by retaining the current scroll position when changing to a fixed position.