-2

my file structure has 'my site' then 3 html pages, a CSS folder and an images folder. When using the background-image tag in CSS how do I access the images in the folder? i tried background-image: url(images/positive.png, but this did not work.]

Thanks

Oli Knight
  • 49
  • 10

3 Answers3

2

The background image is getting fetched from the CSS file. Which means: If your CSS file is located in /Home/style.css and that your background is located at /Home/bg.png, you must specify the following:

background-image url("bg.png");

or:

background-image url("/Home/bg.png");

If the file is located at /bg.png and that your only a folder deep (for example, if your stylesheet is located at /Home/style.css), you can tell the stylesheet to climb up a folder, and then fetch the background, like so:

background-image url("../bg.png");

Hope this helps.

1

Give this is a try...

background-image: url("../images/your-image-name-here.png");

The "../" basically tells the code that it needs to come out of the CSS folder first, then go into the images folder. Without this step, it is looking for an images folder within the CSS folder.

Declan Kay
  • 86
  • 5
0

Try this

background-image: url('../images/positive.png');
ellipsis
  • 12,049
  • 2
  • 17
  • 33