membersound
membersound

Reputation: 86747

How to set a background image in css?

I want to define a image background for a webpage, where the images lies in a subfolder of where the css resource is defined.

path:

src/main/webapp/VAADIN/themes/mytheme/styles.css
src/main/webapp/VAADIN/themes/mytheme/img/logo.png

css:

.root {
    background: url("/img/logo.png") no-repeat;
}

Result: The resource could not be found (firebug). Why? How to I have to specify the path?

Upvotes: 0

Views: 3854

Answers (1)

BackSlash
BackSlash

Reputation: 22233

Remove the first slash, the img folder is in the same folder as styles.css:

background: url("img/logo.png") no-repeat;

Upvotes: 8

Related Questions