简体   繁体   English

CSS 背景图像未加载,但在我检查后加载

[英]CSS background-image not loading, but loads after I inspect it

In one of my websites, I am using css background-image property to set the background for different sections.在我的一个网站中,我使用 css background-image属性来设置不同部分的背景。 All the sections load their background images properly except for the contact section.除联系部分外,所有部分都正确加载了背景图像。

When I try to inspect it, the inspector shows that the background image could not be loaded in the tool tip.当我尝试检查它时,检查器显示无法在工具提示中加载背景图像。 But when I try to open the image in a new tab, I can see the image perfectly, After I do this, when I do a refresh of the page, I am able to see the background image for that section correctly now.但是当我尝试在新选项卡中打开图像时,我可以完美地看到图像,执行此操作后,当我刷新页面时,我现在可以正确地看到该部分的背景图像。 I inspected the Network tab and don't even find the image file being called.我检查了网络选项卡,甚至没有找到正在调用的图像文件。 However, after opening the image in a new tab and then inspecting the network tab shows the image.但是,在新选项卡中打开图像然后检查网络选项卡后会显示图像。

Error when I inspect before trying to open the image in a new tab:在尝试在新选项卡中打开图像之前检查时出错:

在此处输入图片说明

My site can be viewed here .我的网站可以在这里查看。 The error happens in the Contact Section and can be viewed here错误发生在联系部分,可以在这里查看

Please help me with this strange error.请帮我解决这个奇怪的错误。

Because you are getting this error in console:因为您在控制台中收到此错误:

在此处输入图片说明

The HTTP 409 Conflict response status code indicates a request conflict with current state of the server HTTP 409 Conflict 响应状态代码表示请求与服务器的当前状态发生冲突

Your Image Path:您的图像路径:

在此处输入图片说明

The alternative and generally better option is to use a path that's relative to your domain, You should pass your image:另一种通常更好的选择是使用相对于您的域的路径,您应该传递您的图像:

在此处输入图片说明

Please see this post: background images path not working in CSS请参阅这篇文章: 背景图片路径在 CSS 中不起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM