Javascript jQuery。加载屏幕不显示';1秒后脱色
我正在使用此代码使加载屏幕出现1秒,然后消失 ,但它会继续加载 CSSJavascript jQuery。加载屏幕不显示';1秒后脱色,javascript,html,css,wordpress,loading,Javascript,Html,Css,Wordpress,Loading,我正在使用此代码使加载屏幕出现1秒,然后消失 ,但它会继续加载 CSS .preloader { overflow: auto; position: fixed; z-index: 99999; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; background-color: #fefefe; } jQuery( window ).
.preloader {
overflow: auto;
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #fefefe;
}
jQuery( window ).load(
function() {
jQuery( '.status' ).fadeOut();
jQuery( '.preloader' ).delay( 1000 ).fadeOut( 'slow' );
setTimeout( zerif_display_iframe_map, 500 );
}
);
JS
.preloader {
overflow: auto;
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #fefefe;
}
jQuery( window ).load(
function() {
jQuery( '.status' ).fadeOut();
jQuery( '.preloader' ).delay( 1000 ).fadeOut( 'slow' );
setTimeout( zerif_display_iframe_map, 500 );
}
);
使用Javascript中的默认
setTimeout
。在报告中说:
.delay()方法最适合在排队的jQuery效果之间进行延迟。例如,由于它的局限性,它没有提供一种取消延迟的方法。delay()不是JavaScript本机setTimeout函数的替代品,后者可能更适合某些用例
你也应该检查一下怎么做,我必须把它清理干净才能让它工作。
$(函数(){
jQuery('.status').fadeOut();
setTimeout(函数(){
jQuery('.preload').fadeOut('slow');
}, 1000);
});代码>
.preload{
溢出:自动;
位置:固定;
z指数:99999;
排名:0;
右:0;
底部:0;
左:0;
宽度:100%;
身高:100%;
背景颜色:蓝色;
}
我淡出
1999年的一个设计阻止了我,也就是preload,你可以通过javascript
生成必要的容器和元素,并在页面成功加载后删除它们
此外,您甚至不需要jquery
,您可以用普通的javascript和纯css来实现,这可能会更快、更小
为了获得更好的性能,我们可以使用javascript生成svg,而不是使用图像
我之前也做过类似的工作,它会自动生成所有必要的组件,以获得完美的加载屏幕。将以下
放在页面末尾附近,即关闭
标记的正前方
var t=“#2774ab”,u=document.querySelector(“*”),s=document.createElement(“样式”),a=document.createElement(“旁白”),m=”http://www.w3.org/2000/svg,g=document.createElements(m,“svg”),c=document.createElements(m,“圆圈”);document.head.appendChild,(s.innerHTML=“#seller{background:+t+”color:+t+”;显示:flex;对齐项目:居中;对齐内容:居中;位置:固定;顶部:0;高度:100vh;宽度:100vw;z-index:2147483647}@关键帧膨胀{到{变换:旋转(360度)}}#seller svg{动画:.3s膨胀无限线性}),a.setAttribute(“id”,“seller”),document body.prepend(a) 、g.setAttribute(“高度”、“50”)、g.setAttribute(“过滤器”、“亮度(175%))、g.setAttribute(“视图框”、“0 0 100 100”)、a.prepend(g)、c.setAttribute(“cx”、“50”)、c.setAttribute(“cy”、“50”)、c.setAttribute(“r”、“35”)、c.setAttribute(“填充”、“无”)、c.setAttribute(“笔划”、“当前颜色”)、c.setAttribute(“笔划数组”、“165 57”)、c.setAttribute(“笔划宽度”、“10”、g.prepend(c)、(u.style.pointerEvents=“none”)、(u.style.userSelect=“none”)、(u.style.cursor=“wait”)、window.addEventListener(“加载”,函数(){setTimeout(函数(){(u.style.pointerEvents=“”)、(u.style.userSelect=“”)、(u.style.cursor=“”);a.remove()},100)})
您可以在此查看最新版本及其所有文档