我正在尝试为我的网页获取背景图片。我有一个外部样式表的链接,它工作正常(CSS适用),但当我尝试使用background-image
获取背景图像时,它不显示结果。我已经尝试了绝对和相对URL
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="created" content="Wed, 26 Mar 2014 04:01:34 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Welcome to CSS</title>
<link rel="stylesheet" type="text/css" href="welcome.css" />
</head>
<body></body>
</html>
CSS:
body{
background-image:url('C:\Users\Neo\Documents\CoffeeCup Software\My
Website\Files\images.jpg');
background-repeat:repeat-x;
}
答案 0 :(得分:1)
试试这个:
background-image:url('Files/images.jpg');
答案 1 :(得分:1)
您无法从本地设置absolute path
。您可以设置绝对路径仅实时网页。以下方式,
BODY { background-image: url(http://www.bg.com/pinkish.gif) }
设置relative path
的另一种方式。我假设您的根网站文件夹
__My Website
|__Files
|__images.jpg
|__welcome.css
|__welcome.html
它相对于样式表,但我建议根据以下方式根据上面的支撑设置相对路径制作相对于您的网址的网址,
background-image:url('Files/images.jpg');
答案 2 :(得分:0)