我很新手,我怎麼可以添加到我的代碼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');
});
});
你需要更多地解釋什麼是你期待 – dreamweiver
我wan't做那。 http://ifelselab.com/test/dnd2/index2.html這裏我的網站。頁面頂部我們以藝術形式開展業務。此圖像不在幻燈片div。當我推到按鈕我們是誰它必須在導航下,但它不會發生 – user3348410