【问题标题】:background: url(images/2.png) doesn't work in style.css背景:url(images/2.png) 在 style.css 中不起作用
【发布时间】:2015-03-31 20:20:27
【问题描述】:

背景:文件 style.css(位于 web-app/static/styles/style.css 中)中的 url(images/2.png) 无法加载位于 web-app/static/images/2 中的图片 2.png .png .我用的是spring框架

【问题讨论】:

  • 样式表中的图像 URL 是相对于样式表的 URL,因此您需要使用绝对 URL 或使用可以找到图像的相对路径,例如 ../images/2.png跨度>

标签: java css spring jsp


【解决方案1】:

这意味着您的图像位于样式文件夹中的图像文件夹中,即样式 -> 图像 -> 2.png

如果您的图像文件夹位于静态文件夹内,即静态 -> 图像 -> 2.png

,我建议尝试返回文件夹的 ../images/2.png

【讨论】:

    【解决方案2】:

    你做的图片位于 web-app/static/styles/images/2.png

    背景:网址(http://localhost/web-app/static/images/2.png)

    您的图片位置在哪里?

    【讨论】:

    • 我的图片位置在 web-app/static/images/2.png
    • 你正在尝试:背景:url(“../images/2.png”);所以出了一个文件夹
    • 右键单击浏览器(您的页面)-> 检查项目-> 网络。查看和编辑您的图片的位置
    • @SamiKobbi 以及关于您的网络应用,样式表在哪里
    猜你喜欢
    • 2019-05-01
    • 2016-09-22
    • 1970-01-01
    • 2014-01-31
    • 2012-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多