Support the ongoing development of Laravel.io →
posted 10 years ago
Views
Last updated 2 years ago.
0

You should use non-relative URLs in your CSS where possible. For example, if your public directory has this structure:

public

----css

--------cms

------------master.css

----js

----img

--------cms

------------bg_dark.jpg

Your CSS should look like this:

background-image: url("/img/cms/bg_dark.jpg")
Last updated 2 years ago.
0

I have:

public

---css

------cms

---------main.css

---images

------cms

---------bg_dark.jpg

But I have to prefix with the ../../ or it won't work.

Last updated 2 years ago.
0

Your code is correct, the image is relative to the stylesheet, so you need to go up 2 direcotries then down into images/cms/

You could also make it relative to the site root as thepsion5 suggests (begin with a "/")

Last updated 2 years ago.
0

elite123 said:

Your code is correct, the image is relative to the stylesheet, so you need to go up 2 direcotries then down into images/cms/

You could also make it relative to the site root as thepsion5 suggests (begin with a "/")

As I just said his suggestion doesn't work. The image isn't being loaded.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.