0

I cannot load image as a background, my image located at

img/my_images.jpg

and this is my css code look like

.background-content
    {
    background-image: url(img/my_images.jpg);
    background-position: center;
    }

the css file is located at

css/my_style.css

but everytime I move the image into the same folder as css, it does load the image perfectly. is it impossible to load image from outside folder of css

thanks for the help.

sincerely, gema.

1
  • thankss, i solved this problem my self, it needs to be started with "/" first if you wanna go to root folder then to another folder. Thanks stackoverflow. Commented Feb 16, 2015 at 16:36

4 Answers 4

2

I'm guessing here, but you probably just need to use the "up one level" syntax:

background-image: url(../img/my_images.jpg);

This gets you up into the parent folder of /css/, and then back down into /img/.

Sign up to request clarification or add additional context in comments.

Comments

1

Change this

background-image: url(img/my_images.jpg);

to this

background-image: url(../img/my_images.jpg);

Comments

1

The image loads relative to where the css is located. So your image would have to be in

  css/img/my_images.jpg

I'm guessing you want

  background-image: url(../img/my_images.jpg)

I prefer to do everything from the root

  background-image: url(/img/my_images.jpg)

Comments

0

Marcus is correct you likely need to go back a directory with ../images/you pic.jpg

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.