加载所有图像后加载页面
我的背景图像相当大。当我的页面加载时,HTML 在背景图像加载到页面之前呈现。我希望背景图像首先加载到页面上,然后是 HTML。现在看起来很奇怪,因为没有背景图像,文本会被推高,而当加载背景图像时,所有文本都会被推到常规位置(看起来不太专业)。
无论如何,javascript 中是否可以实现此目的?
谢谢!
My background image is decently large. When my page loads, the HTML is rendered before the background image is loaded onto the page. I would like for the background image to be the first thing to be loaded on the page and then the HTML. Right now it looks weird because without the background image, the text gets pushed up and when the background image is loaded, it all gets pushed to its regular position (not too professional-looking).
Is there anyway in javascript to accomplish this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为预加载图像并不能解决您的问题,因为您希望在向用户显示 HTML 文档之前加载图像。
我没有确切的解决方案,但我所做的是在页面加载时向用户显示加载图像,然后在正文和图像完全加载时隐藏该加载图像。做到这一点
这只是一个粗略的代码,希望这有帮助
I think pre-loading an image is not a solution to you problem since you want the Images to load Before the HTML document is displayed to the user.
i dont have an exact solution but what i did was show a LOADING image to the user while the page loads up and then hide that loading image when the body and images are completely loaded. to do this
This is just a rough code, hope this helps
您可以编写 javascript,在加载所有内容后将页面的其余部分添加到 DOM。
这是使用 jQuery 可以做的最简单的事情之一。
但是,我不明白这一点。作为用户,我不希望你对我这样做。
You can write javascript that adds the rest of the page to the DOM once everything is loaded.
It's one of the easiest things you can do with jQuery.
However, I don't see the point. As a user I don't want you to do that to me.