我有一个我正在尝试使用的 CSS Sprite 表,但我的 CSS 文件无法“看到”图像。我已经按照提供的答案 here无济于事。我的包结构是:
src/
vendor/
project/
bundle/
Resources/
public/
css/
normalize.css
static.css
images/
sprites.jpg
我已经完成了:
$ app/console assets:install
Installing assets using the hard copy option
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for MajorProductions\SewingDiva\SiteBundle into web/bundles/majorproductionssewingdivasite
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
和:
$ app/console assetic:dump
Dumping all dev assets.
Debug mode is on.
22:19:13 [file+] /home/kevin/www/diva/app/../web/css/06758be.css
22:19:13 [file+] /home/kevin/www/diva/app/../web/css/06758be_part_1_normalize_1.css
22:19:13 [file+] /home/kevin/www/diva/app/../web/css/06758be_part_1_static_2.css
不知道还能做什么....
最佳答案
通过更改引用来解决它:
{% block styles %}
{% stylesheets '@MajorProductionsSewingDivaSiteBundle/Resources/public/css/*' filter='cssrewrite' %}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
到:
{% block styles %}
{% stylesheets 'bundles/majorproductionssewingdivasite/css/*' filter='cssrewrite' %}
<link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
{% endstylesheets %}
{% endblock %}
显然第一个版本中的 auto-magical reference 不是可行的方法,尽管它被用在官方 Symfony 文档中。
关于css - Symfony2 和 Assetic - 我的 CSS 中引用的图像无法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13784353/