Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony2中CSS资源中的图像_Css_Symfony_Twig_Assets - Fatal编程技术网

Symfony2中CSS资源中的图像

Symfony2中CSS资源中的图像,css,symfony,twig,assets,Css,Symfony,Twig,Assets,我有以下问题: 我将fancybox中的CSS文件包括在我的base.html.twig文件中: {% block head_style %} {% stylesheets '../vendor/twbs/bootstrap/dist/css/bootstrap.min.css' filter='cssrewrite' '@Bundle/Resources/public/css/site.css' filter='cssrewrite' '

我有以下问题:

我将fancybox中的CSS文件包括在我的base.html.twig文件中:

{% block head_style %}
    {% stylesheets
        '../vendor/twbs/bootstrap/dist/css/bootstrap.min.css' filter='cssrewrite'
        '@Bundle/Resources/public/css/site.css' filter='cssrewrite'
        '@Bundle/Resources/public/css/jquery.fancybox.css' filter='cssrewrite'
        %}
        <link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock head_style %}
{%block head\u style%}
{%样式表
“../vendor/twbs/bootstrap/dist/css/bootstrap.min.css”filter='cssrewite'
“@Bundle/Resources/public/css/site.css”filter='cssrewite'
“@Bundle/Resources/public/css/jquery.fancybox.css”filter='cssrerewrite'
%}
{%endstylesheets%}
{%endblock头\样式%}
我的目录如下:

我现在想的问题是fancybox找不到
fancybox\u sprite.png
fancybox\u overlay.png
fancybox\u loading.gif

以下是
jquery.fancybox.css
中的路径之一:

#fancybox加载、.fancybox关闭、.fancybox上一个span、.fancybox下一个span{
背景图像:url('../images/fancybox_sprite.png');
}

以下是浏览器正在查找的路径:

http://project/Resources/public/images/fancybox_sprite.png

我还发现,
/images
目录不会加载到
/web
目录中,而是加载到
/bundles
目录中,尽管我使用了
assets:install
assets:install--symlink
assetic:dump

为什么系统不能读取图像,或者为什么图像没有加载到
/web
目录中


关于这一点,我发现了一些问题,但它们都没有帮助我。

不要将@Bundle符号与cssrerewrite一起使用,它会失败--

您应该从web文件夹中写入css文件的相对路径。使用bin/console assetic:install导出资产后,新的base.html.twig应为:

{% block head_style %}
    {% stylesheets
        '../vendor/twbs/bootstrap/dist/css/bootstrap.min.css' filter='cssrewrite'
        'bundles/something_online/css/site.css' filter='cssrewrite'
        'bundles/something_online/css/jquery.fancybox.css' filter='cssrewrite'
        %}
        <link rel="stylesheet" type="text/css" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock head_style %}
{%block head\u style%}
{%样式表
“../vendor/twbs/bootstrap/dist/css/bootstrap.min.css”filter='cssrewite'
'bundles/something\u online/css/site.css'filter='cssrewite'
'bundles/something\u online/css/jquery.fancybox.css'filter='cssrerewrite'
%}
{%endstylesheets%}
{%endblock头\样式%}