Css 未在Laravel 4中显示的图像
我在这方面遇到了问题-图像无法显示Css 未在Laravel 4中显示的图像,css,laravel-4,Css,Laravel 4,我在这方面遇到了问题-图像无法显示 <div class="carousel-inner"> @foreach ($model->pictures as $picture) <div class="fill" style="background-image:url({{ URL::asset($picture->path) }});"> </d
<div class="carousel-inner">
@foreach ($model->pictures as $picture)
<div class="fill"
style="background-image:url({{ URL::asset($picture->path) }});">
</div>
<!-- {{ HTML::image($picture->path)}} -->
@endforeach
</div>
“fill”类似乎既没有高度也没有宽度。由于您正在为一个没有任何大小的元素定义背景,因此现在将显示该元素本身(即div)
您可以通过定义宽度和高度来解决此问题,如下所示:
<div class="fill"
style="background:url({{ URL::asset($picture->path) }}); no-repeat;
background-size:269px 95px;height:95px;width:269px">
</div>
试试这个:
<div style="height:100px;width:100px;background-image:url('{{ asset('http://www.example.com/images/image.png') }}'); border-radius: 5px;position:relative">
您可以使用图像的绝对路径
例如:
http://www.example.com/images/image.png
另外,尝试在px
中使用width
,而不是在%
注意:最好避免使用内联样式,但既然您已经在背景图像中使用了它,我就继续吧 你能试着把宽度和高度从100%改为100px,看看是否有效吗?
URL::asset($picture->path
http://www.example.com/images/image.png