Click here to Skip to main content
15,844,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm new to laravel and trying to display background image but not working i searched a lot but nothing worked for me

in the public folder i have images folder and asset folder in asset folder i have the css folder

What I have tried:

background-image: url("/images/banner_img.png");

i found this

but this only work in HTML, i need something work in css file

i tried also put public in the url
but not worked and when i click on the link it go to this url >>http://localhost/learning_academy/public/asset/css/public/images/banner_img.png

without public
it go to this url >> http://localhost/images/banner_img.png

when i removed the / in

the url became like this>> http://localhost/learning_academy/public/asset/css/images/banner_img.png when i clicked on it so i don't know why this happens

and in all three the image not showing
Updated 1-Oct-20 15:34pm

Let's talk about the last one:

That is relative to your CSS file.
You said that the link ended up being:

That means your CSS file must be in /localhost/learning_academy/public/asset/css/ right?

To solve this problem we have to know the path to the CSS.

You can actually try the full path just to try it out.
Add the following to your CSS file:
background-image: url("http://localhost/learning_academy/public/asset/css/images/banner_bg.png")

But also you are referring to the image as two different names so a bit confusing:
1) banner_img.png
2) banner_bg.png
Share this answer
Member 12214576 24-Sep-20 17:43pm    
it's the first one "banner_img.png" i will update it,
i added the url in the css file but nothing happens

this is the path of the css files >>

and this is the path of images
it worked after i put the Images folder in the same path folder that have the CSS folder
Share this answer
Richard Deeming 2-Oct-20 4:44am    
As already more than adequately explained in solution 1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900