Smooth scroll to specific div on click

http://stackoverflow.com/questions/18071046/smooth-scroll-to-specific-div-on-click

by Dedi Wibisono

HTML

<div class="first"><button type="button">Click Me!</button></div>
<div class="second">Hi</div>

CSS

.first {
    width: 100%;
    height: 1000px;
    background: #ccc;
}

.second {
    width: 100%;
    height: 1000px;
    background: #999;
}

JavaScript

$("button").click(function() {
    $('html,body').animate({
        scrollTop: $(".second").offset().top - 50},
        'slow');
});