我尝试使用下面的代码在我按下网站中的链接时淡入div内容,然后当我按下另一个链接时淡出,新内容淡入。你可以在这里看到这个例子:
http://www.onextrapixel.com/2010/02/23/how-to-use-jquery-to-make-slick-page-transitions/
嗯,我需要把一个动画gif预加载器放在每个页面的顶部,然后才会加载它。有人能帮我写一下jquery代码吗?谢谢..
交换内容和淡入/淡出的代码:
$(document).ready(function() {
$("#content").css("display", "none");
$("#content").fadeIn(1000);
$("a").click(function(event){
event.preventDefault();
linkLocation = this.href;
$("#content").fadeOut(1000, redirectPage);
});
function redirectPage() {
window.location = linkLocation;
}
});发布于 2012-03-27 00:14:26
使用此选项可添加加载覆盖。
$("a").click(function(event){
event.preventDefault();
linkLocation = this.href;
$("#content").fadeOut(1000, redirectPage);
$("body").append("<div class='LoadingOverlay' />");
}然后使用CSS来控制它的呈现方式。
.LoadingOverlay
{
z-index:1000;
position:fixed;
width:124px;
height:124px;
left:50%;
top:50%;
margin-left:-62px;
margin-right:-62px;
background-image:url(/images/loading51.gif);
}通常,我会在新的ajax调用完成后执行此操作
$(".LoadingOverlay").remove();但是看起来一旦预加载完成,您将加载一个新页面,因此您将不需要这个。
https://stackoverflow.com/questions/9875708
复制相似问题