#Background image wont show

47 messages · Page 1 of 1 (latest)

neon atlas
#

Does anyone know why my background image wont show, did I link in incorrectly

honest flame
#

Try doing /img/Background.jpg with the leading slash so that it looks at the root of your site

#

Are you seeing the background color at all?

neon atlas
#

I was just testing it

#

Ill try that though

tranquil meteor
#

The docs say you're supposed to quote it too?```css
background-image: url("../../media/examples/lizard.png");

honest flame
#

Yeah, I'm not sure how mandatory that is

neon atlas
honest flame
#

It's hard to tell what the issue is from what you've shared

#

If you open the dev console do you see any errors loading the image?

neon atlas
honest flame
#

What's the error

neon atlas
honest flame
#

Try putting the image URL in quotes

#

It's escaping the slash, that's what all that mess is after img

tranquil meteor
#

If the server is a unix filesystem but the user is accustomed to windows, it's possible they need to be more aware of case sensitivity too?

neon atlas
tranquil meteor
#

Windows doesn't really allow such shenanigans. 😄

neon atlas
tranquil meteor
#

And you can load that image in a browser manually?

neon atlas
#

Yes, but ive just noticed when i ctrl click on the path it doesnt take me to the img

#

its like it cant find the path but i swear ive linked it correctly

honest flame
#

Share the url you're loading and the url it thinks is the image

neon atlas
#

and also it doesnt show anything for the url it thinks it is it just comes up with an error in vscode

honest flame
# neon atlas

You mean this screenshot? you can see the URL is mangled to hell

tranquil meteor
neon atlas
#

background: url(/img/Background.jpg);

#

is the url i use

honest flame
#

Put quotes around the url

neon atlas
#

Tried again it doesn't seem to work

honest flame
#

That url is looking in the folder page-framework/css/img which I don't think is correct

#

Are you doing some kind of build step?

#

Is the image url prefixed with the /?

neon atlas
#

It is not no

honest flame
#

That leading slash tells the browser that the image URL is absolute, if you remove it the URL becomes relative to the current URL

neon atlas
#

So i should I not remove the / ?

#

The image is in my source files

honest flame
#

You want the slash at the start. It'll tell the browser to look at 127.0.0.1:5500/img and not at 127.0.0.1:5500/page-framework/css/img

#

So the image is in page-framework/img?

neon atlas
honest flame
#

So your CSS should be /page-framework/img/Background.jpg

neon atlas
#

With quotations ?

#

Oh wow it worked

#

I literally love you

honest flame
#

Awesome!