我的 CSS 链接如下:
{% stylesheets '@MyFrontendBundle/Resources/public/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
此 CSS 文件中的背景图像:
#pic {background-image:url('../../bundles/myfrontend/images/pic.png');}
CSS 和图像文件夹都在 Resources/public/中。 背景图片不会显示。当我在浏览器中查找路径时,它显示
background-image:url('../../Resources/bundles/myfrontend/images/pic.png');
为什么它会在我的路径中添加资源?如果我将 Firebug 中的路径编辑回
background-image:url('../../bundles/myfrontend/images/pic.png');
正在显示背景。
我希望有人能帮我解决这个问题。
P.S.:这个问题在 Linux 上不存在。背景图像显示在那里。
最佳答案
试试这个:
{% stylesheets '@MyFrontendBundle/Resources/public/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}
编辑:
background-image:url('../../../bundles/myfrontend/images/pic.png');
关于css - Mac OS 上的 Symfony2 未找到背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31242748/