John Davidson

php - I want to add a background-image with a laravel URL in my css file. I can do this by just including path?


I want to add a background image with a laravel URL. I can do this by just including the web path itself but I would like to use Laravel URL.

Here is how I do it now in css: {
background: url("{{ asset('assets/img/cancel.png')}}");
background-repeat: no-repeat;
background-size: 25px;
background-position: center;

but it doesn't work

My Answer:

If you want to use a Laravel URL in your CSS file, you can use the `asset()` helper function provided by Laravel. Here's how you can do it: {_ background: url('{{ asset('images/background.jpg') }}');_

This will generate the full URL to the image using the `asset()` function, which will include the base URL of your Laravel application.

Rate this post

4 of 5 based on 6242 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us