CSS背景图像路径问题 [英] CSS Background-Image Path Issues

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

问题描述

在我的CSS中,我有以下:

In amongst my CSS I have the following:

#framecontentTop{
position: absolute;
top: 0;
left: 120px;
right: 0;
height: 100px;
overflow: hidden;
background-image: url(/Users/myname/Website Project/logo.jpg);
color: white;
}

其中我想用作背景图像的路径是/ Users / myname / Website Project / logo.jpg

Where the path to the image I want to use as the background-image is /Users/myname/Website Project/logo.jpg

但是,当我把ID放在ID framecontentTop,它不显示图像(或任何东西)作为背景。 CSS中没有其他div与它冲突,当我将framecontentTop的背景设置为颜色或保持为图像,但将URL作为一些随机图像在线,它加载它很好。所以我只能假设问题是我如何指定的图像的路径 - 任何人都可以看到我在这里做错了吗?

However, when I put in my div with the ID framecontentTop, it doesn't show the image (or indeed anything) as the background. There are no other divs in the CSS to conflict with it, and when I set the background for framecontentTop to a colour or keep it as an image but put the URL as some random image online, it loads it fine. So I can only assume the problem is with how I have specified the path to the image - can anyone see what I have done wrong here?

非常感谢

推荐答案

如果你有任何特殊字符,它们应该被转义,或者在白色空格的情况下, / p>

If you have any special characters, they should be escaped, or in the case of white-space, at least quoted, like this:

background-image: url("/Users/myname/Website Project/logo.jpg");

您可以看到

You can see the W3C Spec for the full requirements.


p>出现在非引号URI中的某些字符(如括号,逗号,空格字符,单引号(')和双引号())必须用反斜杠转义,以使生成的URI值是URI令牌: (',')','\,'。

Some characters appearing in an unquoted URI, such as parentheses, commas, white space characters, single quotes (') and double quotes ("), must be escaped with a backslash so that the resulting URI value is a URI token: '(', ')', '\,'.

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

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