【问题标题】:Laravel 8 Background photo does't appearLaravel 8背景照片不出现
【发布时间】:2021-04-11 11:32:27
【问题描述】:
<div class="site-blocks-cover overlay bg-light" style=" background-image: url('public/template/images/hero_bg_1.jpg')" id="home-section">

照片没有出现在网站顶部。我也没有收到任何错误 the website

【问题讨论】:

  • 如果带有 div 的 HTML 位于公共目录中,则图像的路径不正确。如果是这种情况,请从样式中的图像 URL 中删除 public/

标签: php html css laravel-8


【解决方案1】:

尝试使用 Laravel 的url 函数

background-image:url({{url('template/images/hero_bg_1.jpg')}})

【讨论】:

    【解决方案2】:

    你必须添加 {{url(' ')}} 这个来回显你的图片 所以你的代码必须是

    <div class="site-blocks-cover overlay bg-light" style=" background-image: url('{{url('public/template/images/hero_bg_1.jpg')}}')" id="home-section">
    

    还有一个你可以使用它的asset() 像这样

    <div class="site-blocks-cover overlay bg-light" style=" background-image: url('{{asset('public/template/images/hero_bg_1.jpg')}}')" id="home-section">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 2015-04-23
      • 1970-01-01
      • 2012-12-29
      • 1970-01-01
      相关资源
      最近更新 更多