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