i have a onepage design with some divs together. when i click on menu link ("3") i want to scroll to div #3 and it should be in the vertical middle of the screen.
i tried:
$('#go').click(function() {
$('html,body').animate({ scrollTop: $(.box).offset().top - ( $(window).height() -
$(.box).outerHeight(true) ) / 2 }, 200);
});
it doesn't work. what did i forgot?
here is a fiddle: http://jsfiddle.net/herrfischerhamburg/7CVtm/1/