0
我想爲我的背景圖像使用本地文件,它在我通過文本編輯器預覽時有效,但是當我將更改推送到我的github頁面時,控制檯返回GET http://davez01d.github.io/images/background-1.PNG 404 (Not Found)
。下面是加載背景圖片的腳本 -瀏覽器無法找到背景圖像的文件
var backgroundImages = [
{url: '../images/background-1.PNG', credit: 'http://www.intrawallpaper.com'},
{url: '../images/background-2.JPG', credit: 'David Stewart'},
{url: '../images/background-3.JPG', credit: 'David Stewart'},
{url: '../images/background-4.GIF', credit: 'http://jecichon.tumblr.com'},
];
$('#hero').css('background-image', 'url(' + backgroundImages[Math.floor(Math.random()*backgroundImages.length)].url + ')');
和我的文件結構設置這樣
-Davez01d.github.io
-css
-style.css
-images
-background-1.PNG
-background-2.JPG
-etc.
這樣做!謝謝! – Davez01d