[英]Why I'm having this css background-image referencing issue?
This is fine:这可以:
background-image: url(./dir/img.jpg);
but, I do get a 404 when trying to refer to an image using this method:但是,当尝试使用此方法引用图像时,我确实得到了 404:
index.html
<div style="--url: url(./dir/img.jpg);"></div>
css
background-image: var(--url);
It works fine in local server, but when it's deployed, it won't work.它在本地服务器上工作正常,但部署后,它就无法工作。
Note:笔记:
I believe it has something to do with cdn that is configured by netlify and so far my solution is to provide full path: https://example.com/parent/child/image.jpg我相信它与netlify配置的cdn有关,到目前为止我的解决方案是提供完整路径: https://example.com/parent/child/image.jpg
The 404 error on dev tools console shows a cdn link — I believe:开发工具控制台上的 404 错误显示了一个 CDN 链接——我相信:
Error: https://d33wubrfki0l68.example.net/parent/child/image.jpg
Works: https://d33wubrfki0l68.example.net/parent/child/[somehashes–idk]/image.jpg
instead of:代替:
https://example.com/parent/child/image.jpg
Please enlighten me.请赐教。
If it works on the local server there must be a problem with the image or the server, not the code.如果它在本地服务器上工作,则一定是图像或服务器有问题,而不是代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.