[英]Why I'm having this css background-image referencing issue?
这可以:
background-image: url(./dir/img.jpg);
但是,当尝试使用此方法引用图像时,我确实得到了 404:
index.html
<div style="--url: url(./dir/img.jpg);"></div>
css
background-image: var(--url);
它在本地服务器上工作正常,但部署后,它就无法工作。
笔记:
我相信它与netlify配置的cdn有关,到目前为止我的解决方案是提供完整路径: https://example.com/parent/child/image.jpg
开发工具控制台上的 404 错误显示了一个 CDN 链接——我相信:
Error: https://d33wubrfki0l68.example.net/parent/child/image.jpg
Works: https://d33wubrfki0l68.example.net/parent/child/[somehashes–idk]/image.jpg
代替:
https://example.com/parent/child/image.jpg
请赐教。
如果它在本地服务器上工作,则一定是图像或服务器有问题,而不是代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.