html - 即使我使用 url ('../../images/image.png' 背景图像路径也不起作用)

标签 html css background-image

当我给出背景图像路径时,我收到 Failed to load resource: the server responded with a status of 404 (Not Found) 错误:

body {
    background-image: url('../../images/img.png') !important;
    background-color: #d0dfe5 !important;
    background-repeat: repeat;
    font-size: 14px !important;
}

我不知道为什么会收到此错误。路径上有什么我需要改变的吗? 请帮助我。

最佳答案

问题是你的css中的路径

background-image: url('../../images/image.png') !important;

您在“personaltitania/WebContent/styles/personaltitania_base.css”中,图像文件在“WebContent/images/”中,但您返回了两个级别当您使用“../../”时,此时您尝试在“personaltitania/images”中找到图像“image.png”。

尝试使用

background-image: url('../images/image.png') !important;

而且,我在您的图像文件夹中没有看到文件“image.png”

关于html - 即使我使用 url ('../../images/image.png' 背景图像路径也不起作用),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34459781/

相关文章:

html - 如何将文本居中放置在同一行左侧有一些文本的位置

javascript - 在固定元素上使用 fullpagejs 滚动

jquery - 奇怪的 <div> 位置(在 jQuery 函数期间四处移动)

javascript - 检查是否选中了带有多个复选框的 html 表上的特定复选框。 JS/JQuery

jquery - 我使用 div 添加了背景图像

javascript - jQuery 读取的 CSS 与 jQuery 设置的 CSS 不对应

html - 图片位于链接之上,但我需要我的链接可以点击

css - iOS 12 Cordova 应用程序 : SVG as webkit-mask-image shows strange border

c# - 将背景图像添加到 asp.net 主网页 asp.net 4.0 和 html5

javascript - 如何从背景 CSS 属性获取多个图像 URL?