它在Firefox和chrome上可以正常工作,但是Safari似乎有一些问题.这是代码.
function founders() {
var scrollPos = $(window).scrollTop();
if (scrollPos == 900) {
$(function() {
$(".first_fall").fadeIn(1000);
$(".second_fall").fadeIn(2000);
$(".third_fall").fadeIn(3000);
});
};
}
这就是我所说的
$(document).ready(function(e) {
$(window).bind('scroll', function() {
founders();
});
});
相同的功能在不同页面上的Safari和chrome上效果很好.
$(function() {
$(window).bind('scroll', function() {
zoomed();
});
}());
function zoomed() {
var scrollPos = $(window).scrollTop();
if (scrollPos >= 500 && scrollPos <= 800) {
$(function() {
$('#icon_you').animate({
opacity: 0
});
$('.about_head').animate({
opacity: 1
});
});
} else {
$(function() {
$('.about_head').animate({
opacity: 0
});
$('#icon_you').animate({
opacity: 1
});
});
};
if (scrollPos >= 1100 && scrollPos <= 1500) {
$(function() {
$('.about_company_head').animate({
opacity: 1
});
$('#icon_company').animate({
opacity: 0
});
});
} else {
(function() {
$('.about_company_head').animate({
opacity: 0
});
$('#icon_company').animate({
opacity: 1
});
});
};
if (scrollPos >= 1700 && scrollPos <= 2200) {
$(function() {
$('.about_project_head').animate({
opacity: 1
});
$('#icon_project').animate({
opacity: 0
});
});
} else {
$(function() {
$('.about_project_head').animate({
opacity: 0
});
$('#icon_project').animate({
opacity: 1
});
});
};
if (scrollPos >= 2700 && scrollPos < 3200) {
$(function() {
$('.about_practical_head').animate({
opacity: 1
});
$('#icon_practical').animate({
opacity: 0
});
});
} else {
$(function() {
$('.about_practical_head').animate({
opacity: 0
});
$('#icon_practical').animate({
opacity: 1
});
})
};
}
解决方法:
尝试
var scrollPos = $(“ body”).scrollTop();
Webkit浏览器始终将window / html scrollTop呈现为零.