0
我想爲我的標題添加懸停效果,但前提是用戶位於頁面頂部。我正在與shopify合作,我認爲最好的方法是當你將鼠標懸停在上面並更改一些CSS屬性(如文本顏色和高度)時,它會添加一個類。如果你滾動,我已經得到了這個代碼。如果將鼠標懸停在元素上,可以編輯此代碼嗎?但只有在scrollTop = 0
?只有當scrollTop = 0時,jQuery纔會懸停
$(document).ready(function() {
(function() {
$(document).on('shopify:section:load', function(event) {
jQuery(window).trigger('resize').trigger('scroll');
var Heightcalculate = $('header').height();
// Responsive edits
if($(window).width() > 980){
//caches a jQuery object containing the header element
var header = $(".scrollheader");
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 1) {
header.removeClass('scrollheader').addClass("coverheader");
$('#phantom').show();
$('#phantom').css('height', Heightcalculate+'px');
} else {
header.removeClass("coverheader").addClass('scrollheader');
$('#phantom').hide();
}
});
}
$('.no-fouc').removeClass('no-fouc');
$('.load-wait').addClass('hide');
});
謝謝。是否有可能默認添加該類並通過懸停將其刪除?有點像相反。我還需要更改#actuallogo類的默認background-img src和.scrollheader的文本顏色... – Geatrix
@Geatrix不用客氣。如果你有另一個問題,你應該再發一個帖子。你應該對每個帖子都有一個明確的問題,並在帖子本身中保留詳細信息。 –
謝謝。我現在正在嘗試。我編輯了這樣的代碼:$ header.removeClass('nohover'); ('nohover')){ $ header.addClass('nohover');函數(){ } } } – Geatrix