加载所有背景图像时显示页面

时间:2015-11-13 12:05:55

标签: javascript jquery html css

我希望只有在我的大背景图片加载后才会显示其中的页面和内容。我已经尝试了很多方法来做到这一点,我无法找到方法。 已经尝试过$(document).ready - not working。



body
{
	padding: 0;
	margin: 0;
	background-color: #ffffff;
	width: 100%;
	overflow-x: hidden;
	background: url('images/dark.jpg');
	background-attachment: fixed;
	background-size: cover;
}




3 个答案:

答案 0 :(得分:1)

您可以显示加载动画的叠加层

<div id="preloader"></div>

#preloader 
{ 
    position: fixed; 
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 9999;
    background: #FFFFFF url('URL TO AN ANIMATED LOADING GIF') no-repeat center center; 
}

并在加载所有内容后将其设置为display: none

window.onload = function() {
    document.querySelector('#preloader').style.display = "none";
};

答案 1 :(得分:0)

您可以使用setTimeout函数在背景后显示数据。

由于

答案 2 :(得分:0)

试试这个:

您必须为每张图片执行此操作。例如:

The entity type 'Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin<string>' requires a key to be defined.

希望这有帮助!

相关问题