user1656808
user1656808

Reputation:

How can I show an image as a background of a div?

inside home.html :

<div id="footer">
    this is working!!!
</div>

in css file:

#footer
{
    height: 70px;
    background-image:url('footer.png'); 
    border: 1px solid #000;
}

I check the url of image again & again.. But I cannot see the image as background in footer div. what is the reason. please help me

Upvotes: 1

Views: 90

Answers (2)

NullPointerException
NullPointerException

Reputation: 3804

The syntax seems to be fine

Put the path relative to the css file

e.g. if your files are located as

WEB-INF
|     | css
|     |      your.css
|     | images
|     |      footer.png

Then use

 background-image:url('../images/footer.png'); 

You could use firebug to look for the correct path, you can edit the url by putting ../../images and once the image is visible update your css file with the same data.

Upvotes: 5

Toon Casteele
Toon Casteele

Reputation: 2579

The syntax is fine basically.

The path to the image is probably wrong. Try ../ to go up one folder from your css file or /yourpath/footer.png to start from the root folder.

Upvotes: 1

Related Questions