[英]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.