2014-03-06 44 views
0

我很新手,我怎麼可以添加到我的代碼scrollTop頁邊距+ 100px? 頁面上有一些邊距,但我找不到他。我無法理解在JavaScript文件中輸入margin-top的位置。如何添加scrollTop選項

/************* 
* = Parallax * 
*************/ 
jQuery(document).ready(function ($) { 
    //Cache some variables 
    var links = $('.nav').find('li'); 
    slide = $('.slide'); 
    button = $('.button'); 
    mywindow = $(window); 
    htmlbody = $('html,body'); 

    //Create a function that will be passed a slide number and then will scroll to that slide using jquerys animate. The Jquery 
    //easing plugin is also used, so we passed in the easing method of 'easeInOutQuint' which is available throught the plugin. 
    function goToByScroll(dataslide) { 
     var offset_top = (dataslide == 1) ? '0px' : $('.slide[data-slide="' + dataslide + '"]').offset().top; 

     htmlbody.stop(false, false).animate({ 
      scrollTop: offset_top 
     }, 1500, 'easeInOutQuart'); 


    } 

    //When the user clicks on the navigation links, get the data-slide attribute value of the link and pass that variable to the goToByScroll function 
    links.click(function (e) { 
     e.preventDefault(); 
     dataslide = $(this).attr('data-slide'); 
     goToByScroll(dataslide); 
     $(".nav-collapse").collapse('hide'); 
    }); 

    //When the user clicks on the navigation links, get the data-slide attribute value of the link and pass that variable to the goToByScroll function 
    $('.navigation-slide').click(function (e) { 
     e.preventDefault(); 
     dataslide = $(this).attr('data-slide'); 
     goToByScroll(dataslide); 
     $(".nav-collapse").collapse('hide'); 
    }); 
}); 
+0

你需要更多地解釋什麼是你期待 – dreamweiver

+0

我wan't做那。 http://ifelselab.com/test/dnd2/index2.html這裏我的網站。頁面頂部我們以藝術形式開展業務。此圖像不在幻燈片div。當我推到按鈕我們是誰它必須在導航下,但它不會發生 – user3348410

回答

0

把這個點擊事件中的「滾動到頂部」按鈕/鏈接/任何..

$("body").scrollTop(100); 
+0

如何?我不明白 – user3348410

+0

如果你可以讓小提琴,它真的很簡單.. –

+0

對不起,我不是說它簡單,我的意思是你非常接近。 –