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:
.mystyle{
background-image: url("www.myproject.com/assets/img/background.png")
}
Here is how I want it:
.mystyle{
background-image: url("{{ URL::asset('assets/img/background.png }}")
}
Any clues?
The url() CSS function is used to include a file. The parameter is an absolute URL, a relative URL, a blob URL, or a data URL. The url() function can be passed as a parameter of another CSS functions, like the attr() function.
I have used inline css for a class and this is what actually worked in my case
style=" background-image: url('{{asset('images/cover.jpg')}}');"
You can even use it like this:
.mystyle{
background-image: url("/assets/img/background.png")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With