Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add background image in laravel 5

I am trying to add a background image for my website in Laravel 5.

I've used this in my css file.

html {
        background-image: url("images/background.jpg");
    }

the image is in the public folder of my Laravel project folder. I tried all the paths but it just doesn't load.

I keep getting this error:

http://Laravelproject.app:8000/background.jpg 404 (Not Found)

Any help would be appreciated. Thanks.

like image 317
Harsh Avatar asked Dec 25 '16 19:12

Harsh


3 Answers

Works just fine with slash:

html {
    background: url("/images/background.jpg");
}
like image 77
Alexey Mezenin Avatar answered Nov 11 '22 08:11

Alexey Mezenin


Might be answering a little late but do this and hope it helps someone out there:

background-image:url({{url('images/php_mysql.jpg')}})
like image 20
Ndong Akwo Avatar answered Nov 11 '22 09:11

Ndong Akwo


i am still unable to access image via css in Laravel 6

but

this code is work for me

(add image path in blade.php file)

<div id="loading" style="background-image: url('{{ asset('img/big-loader.gif')}}');">
like image 6
Adnan Zaheer Avatar answered Nov 11 '22 09:11

Adnan Zaheer