我在 laravel 資源/sass/app.scss 中。在這樣的代碼中:
.card {
..
background: url(/img/plus-green.png) no-repeat;
..
}
是否可以根據網站位置創建一個 url,例如url(<?=url('/imgs/img.png')?>),如果網站位于我的本地主機 xampp http://localhost/myproj/public/imgs/img.png 或實時https://example.com/imgs/影像.png。我正在尋找對 css 的動態 url。
uj5u.com熱心網友回復:
您應該使用相對路徑而不是絕對路徑。
在此處閱讀有關相對路徑與絕對路徑的更多資訊。
你應該改變你的代碼:
.card {
..
background: url(/img/plus-green.png) no-repeat;
..
}
至
.card {
..
background: url(img/plus-green.png) no-repeat;
..
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/517001.html
標籤:css拉拉维尔
下一篇:HTML上的高寬空白
