繁体   English   中英

css 样式中的背景图像在带有顺风的 laravel 中不起作用

[英]background-image in css style doesn't work in laravel with tailwind

背景图片没有出现,图片路径是正确的,我用它测试它是有效的>>

<div class="flex items-end justify-end w-full h-56"
     style="background-image: {{url("/storage/images/services/".$order->image)}}">
    <a href="{{route('services.details', $order)}}">
        <button
            class="p-2 mx-5 -mb-4 text-white bg-blue-600 rounded-full hover:bg-blue-500 focus:outline-none focus:bg-blue-500">
            <svg class="w-5 h-5" fill="none" stroke-linecap="round"
                 stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24"
                 stroke="currentColor">
                <path
                    d="M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z"></path>
            </svg>
        </button>
    </a>
</div>
<div class="px-5 py-3">
    <h3 class="text-gray-700 uppercase">{{ $order->name }}</h3>
    <span class="mt-2 text-gray-500">{{ $order->price }}</span>
</div>

您还需要将 url 包装在 css url() function 中:

background-image: url({{ url('storage/images/services/' . $order->image) }})"

url() 文档

背景图像文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM