How can i set the width of the Navigation during scrolling. The Navigation fits 100% width during scrolling. If i set the width to 500px than its left:0 positioned. At left i cant set auto center the Navigation.
$(function() {
var sticky_navigation_offset_top = $('#sticky_navigation').offset().top;
var sticky_navigation = function(){
var scroll_top = $(window).scrollTop(); // our current vertical position from the top
if (scroll_top > sticky_navigation_offset_top) {
$('#sticky_navigation').css({ 'position': 'fixed', 'top':0, 'left':0 });
} else {
$('#navigation_menu').css({ 'position': 'relative' });
}
};
sticky_navigation();
$(window).scroll(function() {
sticky_navigation();
});
});
Try this: http://jsfiddle.net/aY8a7/1/