【问题标题】:How to access images in css file in symfony template如何在 symfony 模板中访问 c​​ss 文件中的图像
【发布时间】:2012-01-12 12:07:02
【问题描述】:

在 html 文件中,我可以使用资产功能访问图像文件夹,但在我的 css 中,我无法使用图像

background-image:url(../images/back.png)

{% stylesheets 'css/*' %}
<link href="{{ asset_url }}" rel="stylesheet" media="screen" />
{% endstylesheets %}

如何解决这个问题

【问题讨论】:

    标签: php html templates symfony fosuserbundle


    【解决方案1】:

    我用这个:

    background-image: url(/bundles/yourbundle/images/pic.png)
    

    无需 cssrewrite 过滤器即可工作。

    【讨论】:

      【解决方案2】:

      这也是我一直困惑的事情!无论如何,有一个 cssrewrite 资产过滤器应该帮助您解决这个问题,检测和重写 css 脚本中的 url(无论如何,即使使用它,您可能需要更改 css 中的 url)。

      【讨论】:

      • 投反对票,因为这个答案含糊不清,无助于解决问题。
      猜你喜欢
      • 2021-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-17
      • 1970-01-01
      • 2017-08-18
      相关资源
      最近更新 更多