使用CSS加载背景图像时出现问题(Aptana Studio)
我使用下面的CSS为我的菜单设置背景图像使用CSS加载背景图像时出现问题(Aptana Studio),css,aptana,aptana3,Css,Aptana,Aptana3,我使用下面的CSS为我的菜单设置背景图像 #menuContainer { background:url('../images/main-bg.png') repeat-x; } 我的CSS在里面 ~/styles/site.css 我的形象就在里面 ~/images/main-bg.png 问题是,这在Chrome上非常有效,但在Firefox上却不起作用。 但是如果将URL更改为 #menuContainer { background:url('images/main-
#menuContainer
{
background:url('../images/main-bg.png') repeat-x;
}
我的CSS在里面
~/styles/site.css
我的形象就在里面
~/images/main-bg.png
问题是,这在Chrome上非常有效,但在Firefox上却不起作用。
但是如果将URL更改为
#menuContainer
{
background:url('images/main-bg.png') repeat-x;
}
它开始在Firefox中工作,但在Chrome中不起作用
有人能帮忙吗?这行吗:
#menuContainer
{
background-image:url('./../images/main-bg.png') repeat-x; /* or './../img/main-bg.png' */
}
如果您有域名或正在运行localhost,那么您应该尝试使用绝对路径来获取图像,因为我觉得问题在于浏览器如何解析相对路径:
#menuContainer
{
background-image:url('wwww.example.com/images/main-bg.png') repeat-x; /* or 'localhost:8080/images/main-bg.png' - please replace 8080 with the port you are using. */
}
这是否有效:
#menuContainer
{
background-image:url('./../images/main-bg.png') repeat-x; /* or './../img/main-bg.png' */
}
如果您有域名或正在运行localhost,那么您应该尝试使用绝对路径来获取图像,因为我觉得问题在于浏览器如何解析相对路径:
#menuContainer
{
background-image:url('wwww.example.com/images/main-bg.png') repeat-x; /* or 'localhost:8080/images/main-bg.png' - please replace 8080 with the port you are using. */
}
换成这个
#menuContainer
{
background:url('../img/main-bg.png') repeat-x;
}
换成这个
#menuContainer
{
background:url('../img/main-bg.png') repeat-x;
}
这似乎是我的一个错误。我一直在使用Aptana Studio查看我的网站。当我从Aptana运行页面时,它会自动打开Firefox,当它打开时,它不会呈现图像。它使用一种叫做Firefox内部服务器的东西。我认为问题就在那里。最后,我试着在Firefox和Chrome中打开网页,在windows资源管理器中右键单击Index.html,它在两种浏览器中都能正常工作。谢谢大家的支持。这似乎是我的错误。我一直在使用Aptana Studio查看我的网站。当我从Aptana运行页面时,它会自动打开Firefox,当它打开时,它不会呈现图像。它使用一种叫做Firefox内部服务器的东西。我认为问题就在那里。最后,我试着在Firefox和Chrome中打开网页,在windows资源管理器中右键单击Index.html,它在两种浏览器中都能正常工作。感谢大家的支持。刚刚注意到您的图像文件夹名为img,在样式表中,您将该文件夹称为图像。这是一个类型错误吗???很抱歉,这是一个输入错误。我的图像在名为images的文件夹中。刚刚注意到您的图像文件夹名为img,在样式表中,您将该文件夹称为images。这是一个类型错误吗???很抱歉,这是一个输入错误。我的图像在名为图像的文件夹中。你的html文件在哪里?是在“~/*.html”吗?作为测试,您可以将html文件移动到styles文件夹中,并检查您以前的代码或我的代码是否在两种浏览器中都工作?我的html文件位于根文件夹中。将html移到styles文件夹中不是一个选项,而且无论如何也不起作用。是的,我也认为这与解析相对路径有关。你的html文件在哪里?是在“~/*.html”吗?作为测试,您可以将html文件移动到styles文件夹中,并检查您以前的代码或我的代码是否在两种浏览器中都工作?我的html文件位于根文件夹中。将html移到styles文件夹中不是一个选项,而且无论如何也不起作用。是的,我也认为这与解决相对路径有关。检查对问题的评论。检查对问题的评论。