在外部样式表中不显示背景图像

the*_*999 0 css background image

不知道发生了什么,但由于某种原因,在外部样式表中链接时我的背景图像没有显示.

例1 :(工作)

<html>
<head>
    ...
</head>
<body style="background: url(images/image.jpg);">
    ...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

例2 :(非工作 - 外部css文件)

body {
    background: url(images/image.jpg);
}
Run Code Online (Sandbox Code Playgroud)

当/如果我使用第一个示例时,将显示图像,但是当我使用第二个示例时,不会显示图像.

有什么建议?先谢谢你...

kei*_*and 7

存储外部CSS文件的目录可能与放置内联样式的页面目录不同.您可能需要使用斜杠开始路径.

url(/images/image.jpg)
Run Code Online (Sandbox Code Playgroud)

或者可能回到像这样的目录

url(../images/image.jpg)
Run Code Online (Sandbox Code Playgroud)