Trying to use a background image in...

User 2283504 Photo


Registered User
36 posts

I am trying to use a background image in my style sheet. I looked at prior posts and came up with the code below but it is not working. Can anyone tell me what is missing or extra?

body {background-image: url("/images/B-ivy-league_v3.jpg"); }

Thank you in advance,

Bryon
Bryon K. Smith
User 187934 Photo


Senior Advisor
20,271 posts

Did you check to make sure the image is in the images directory. Also where is your style sheet located compared to where your images directory is located. You might need this.
body {background-image: url("../images/B-ivy-league_v3.jpg"); }
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 38401 Photo


Senior Advisor
10,951 posts

Also double check your caps on the file name. The path file names need to be exactly the same capitalization as the file names are.

If you have a link to your page it would help us help you much better too :)
User 2276240 Photo


Registered User
194 posts

I have a background image on my Home page and this is what I have
<style type="text/css">
<!--
BODY { font-family: Arial, Georgia, Sans-serif; font-size: medium; font-weight: 600;
background-image: url("Graphics/Corvette_Back.png") }
-->
</style>
the path specifies to look in the graphics folder, which is a sub folder of the main folder that holds all of the HTML doc.
User 2283504 Photo


Registered User
36 posts

I used Eric's solution and it worked like a charm. However,for my education why would this work:

body {background-image: url("../images/B-ivy-league_v3.jpg"); }

and not this:

body {background-image: url(“/images/B-ivy-league_v3.jpg”); }


when the images folder is a sub-folder of the root directory?

Thank you.

Bryon

Bryon K. Smith
User 187934 Photo


Senior Advisor
20,271 posts

Bryon. Read this.:)
http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 122279 Photo


Senior Advisor
14,649 posts

Something is wrong in that article! Check these examples of relative paths:

index.html
/graphics/image.png
/help/articles/how-do-i-set-up-a-webpage.html

The initial slash has to be removed from the two examples with one or two subfolders. The html Editor does not add those slashes, and if I do manually, the image or whatever file it is doesn't show.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 187934 Photo


Senior Advisor
20,271 posts

Inger found a cookie.:) I never noticed that before. Good catch.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 122279 Photo


Senior Advisor
14,649 posts

I have reported it, and Scott has promised to get it fixed. :)
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.