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?

0 comments
Message:


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:


.toggle.active {
background: url("{{ asset('assets/img/cancel.png')}}");
background-repeat: no-repeat;
background-size: 25px;
background-position: center;
}

but it doesn't work



My Answer:
url('/images/background.jpg');_

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:

_.toggle.active {_ 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

Comments




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