Reutelkeutel
Reutelkeutel

Reputation: 29

Css background not appearing with external stylesheet?

When the styles were just listed on the page everything worked fine. Now I made it an external stylesheet and everything still works, except for the background. The image is located in resources. Should the url be changed? I tried adding resources/ or putting it in a folder but nothing seems to work...

body{
    background-image:url(background.jpg);
    background-attachment:fixed;
    color: white;
    font-family: Georgia, "Times New Roman", Times, serif;
    /*font-size: 1.52em;*/
}

It's for a school project and I'd really appreciate help on this...

Upvotes: 0

Views: 73

Answers (2)

VGR
VGR

Reputation: 44414

If your stylesheet is loaded using <h:outputStylesheet>, you cannot refer to a bundled image that way. Use the built-in resource Map instead:

background-image: url("#{resource['myImages:background.jpg']}");

(assuming your images are in the resources/myImages directory).

Upvotes: 0

themunna
themunna

Reputation: 47

You should change the URL. If your image is in site root > img > imagefile and the html is in root and your css is in root > css > cssfile then you should use

background-image: url(../img/imagefile)

Upvotes: 1

Related Questions