首页 文章

图像未在Laravel 4 Framework中显示

提问于
浏览
0

我正在使用Laravel 4 Framework,我试图在我的页面上显示一些图像 . 我有两种不同的情况 . 一,我使用图像作为CSS文件中的背景 . 该图像位于公共文件夹内的文件夹“资产”内的“图像”文件夹中 . 值得注意的是:

.banner-image{background:transparent url('/assets/images/hires_080820-F-5957S-987c.jpg') no-repeat center center;-webkit-background-size:cover;-moz-background-size:cover;background-size:cover; height:800px; min-width: 1200px;}

在视图中,我使用以下方法调用CSS: <div class="banner-image"></div>

在页面上,div显示为空白区域(占用分配的像素),但图像未显示 .

在同一视图中,我使用html调用另一个图像:

<img src="/assets/images/fanssignupsplash.png">

但是,图像显示为断开的链接 . 在Laravel 4中还有另外一种用来调用图像的风格吗?感谢您对这些问题的帮助 .

3 回答

  • 2

    对于CSS,请确保该图像位于名为 assets, at the same level as the CSS file 的文件夹中 . 然后尝试这个:

    .banner-image
    {
      background: url('assets/images/hires_080820-F-5957S-987c.jpg');
    }
    

    在您的视图中,尝试:

    <img src="{{asset('assets/images/fanssignupsplash.png')}}">
    

    假设您的公共目录中有assets文件夹 .

  • 3

    尝试查看{{HTML :: image('images / fanssignupsplash.png')}}

  • 1

    另一种方式,在视图文件中

    <img src="{{ URL::asset('assets/images/fanssignupsplash.png')}}" />
    

    fanssignupsplash.png 图片需要在 http://example.com/assets/images/fanssignupsplash.png

相关问题