我正在 Atom 编辑器中构建一个 bootstrap-4 元素,我的问题是我的 CSS background-image url() 没有显示... 我可以在我的开发人员控制台中看到该文件,但出现错误 - 无法加载资源:服务器响应状态为 404(未找到)。
在你们所有人将我的问题标记为重复等之前,请给我一个机会说我已经解决了几乎所有关于这个问题的现有问题,但到目前为止我尝试的一切都没有奏效,而且它真的令人沮丧。
我试过每一个文件路径调整都没有结果。如果这很简单,那么我希望 stackoverflow 的代码之神对这个问题有所怜悯,我几乎是中级水平,所以我会很感激你的帮助。提前致谢。
我的文件结构: https://imgur.com/a/Ryxr3nf
body {
overflow-x: hidden;
font-family: 'Poppins', sans-serif;
color: #505962;
}
.navbar {
font-weight: 400;
font-size: 1.2rem;
background: rgba(0, 0, 0, 0.6)!important;
}
#gint {
word-spacing: 1.5px;
}
.navbar-dark .navbar-nav .nav-link {
color: white;
}
.navbar-dark .navbar-nav .nav-link.active,
.navbar-dark .navbar-nav .nav-link:hover {
color: #1ebba3;
}
/*--start landing page--*/
.home-inner {
background-image: url(images\landing.jpeg);
}
最佳答案
假设文件路径是正确的,我看到两个问题:
- 您应该使用正斜杠,而不是反斜杠 - 即
images/landing.jpeg
,不是images\landing.jpeg
- 您需要将文件路径用引号括在括号内:
background-image: url('images/landing.jpeg')
关于html - CSS 背景图像 url() 在各种浏览器中未显示错误 '404 not found',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54509475/