我想为搜索创建一个粘性标题,而不是菜单。有人能告诉我在哪里可以更改代码吗?我找到了journal.js
和jquery.sticky.js
。这是关于粘性菜单的journal.js
的剪辑代码:
Journal.enableStickyHeader = function (padding) {
var header = $('.header');
Journal.stickyHeaderHeight = $('header').outerHeight();
var lastScroll = 0;
$('.header-notice').each(function() {
Journal.stickyHeaderHeight += $(this).outerHeight();
});
header.css('top', '-' + (Journal.stickyHeaderHeight) + 'px');
$(window).scroll(function() {
var currentScrollPosition = $(window).scrollTop();
if ($(window).scrollTop() > 1 * (Journal.stickyHeaderHeight) ) {
$('body').addClass('is-sticky').css('padding-top', Journal.stickyHeaderHeight + padding);
header.css('top', 0);
if (currentScrollPosition < lastScroll) {
header.css('top', '-' + (Journal.stickyHeaderHeight) + 'px');
$('.tablet .is-sticky .mega-menu').hide();
}
if(Journal.hasStickyScroll) {
lastScroll = currentScrollPosition;
}
} else {
$('body').removeClass('is-sticky').css('padding-top', padding);
}
});
};
从这里使用Sticky JS:http://stickyjs.com
我已使用$('header')
更改了$('#search')
,但仍无效。这里有人有同样的问题吗?我使用的是Journal 2 Theme和Opencart 1.5.6.4