背景图像不会出现 [英] Background image wont show up

查看:98
本文介绍了背景图像不会出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我想重复的背景图片(repeat-x),但是当我尝试查看页面时,什么也没有显示出来。我也使用JavaScript来为一天中的不同时间使用不同的CSS文件,但我相信这不是问题,因为firebug显示CSS文件已添加到头部。



编辑:问题是浏览器找不到文件,但是当我尝试链接到它时,它仍然找不到该文件。



您可以在此下载网站的存档:
http://cdn.duffcraft.net.adam543i.net/sitebkp-1845.zip
它只有200左右kb。没有大规模的。

解决方案

你确定图像文件的路径是正确的? Firebug会加载图片吗?

您的文件结构可能是这样的

  index.html 
css /
style.css
img /
night /
night-tile.png

现在,从您的 style.css ,您必须使用相对路径来映像文件。所以不是 img / night / night-tile.png 但是 ../ img / night / night-tile.png 。在你的路径中,它正在寻找 css 目录中的图片,这是错误的。 $ b = =更新==



下载您的代码后,我发现2个更多的错误。 ; 你链接到你的样式表的元素。这样,浏览器就不会知道它是样式表。



第二个是你忘记在中添加您的 night.css 中第一条规则的结尾,导致出现分析错误,导致不显示背景规则。



祝你好运解决这些问题!


I have a background image that I want to repeat across (repeat-x) however when I try to view the page, nothing shows up. I'm also using javascript to use a different CSS file for different times of the day, however I am sure that is not the problem because firebug shows that the CSS file was added to the head.

Edit: The problem is that the browser cannot find the file, however when I attempt to link to it, it still cannot find the file.

You can download the archive of the site here: http://cdn.duffcraft.net.adam543i.net/sitebkp-1845.zip Its only 200 or so kb. Nothing massive.

解决方案

And you are sure the path to your image file is correct? Does Firebug load the image?

Your file structure is probably like this

index.html
css/
    style.css
img/
    night/
        night-tile.png

Now, from your style.css you have to use a relative path to your image file. So not img/night/night-tile.png but ../img/night/night-tile.png. In your path it is looking for the image within the css directory, which is wrong.

==Update==

After downloading your code I found 2 more errors.

The first is that you forgot to add rel=stylesheet to the <link> element in which you link to your stylesheet. This way, browsers will not know it's a stylesheet.

The second is that you forgot to add a ; at the end of your first rule in your night.css, resulting in a parse error which causes the background rule not to be rendered.

Good luck fixing these issues!

这篇关于背景图像不会出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆