2016-03-04 98 views
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. 

回答

1

扩展你有你的github上与小写的文件。用png,jpg,gif替换PNG,JPG,GIF,它可以工作。

+0

这样做!谢谢! – Davez01d