How do I use a publicly hosted image as the background for a visualforce page?

396 views Asked by At

I'm trying to use this image as the background for a visualforce page without repeats. This is the code I have so far, but it's not working. Do I have to save the image in Salesforce first. If so, could you walk me through that? Thanks.

<body style="background-image: url('{http://www.jpl.nasa.gov/spaceimages/images/mediumsize/PIA17011_ip.jpg}')no-repeat top fixed;">
2

There are 2 answers

0
Daniel Ballinger On

Visualforce will provide the body tag for you. Instead you should use a style element or <apex:stylesheet/> to define the body style.

See Using Custom Styles

0
Raul On

The image you want to use for body tag is pointing to outside salesforce, hence it might be blocked.

Solution could be:

  1. Either download the image in static resource and use tag as mentioned by Daniel, which is always a good practice.

  2. Add the URL in the remote site setting from setup.