Search code examples
cssbackground-imagepixel

How to make a an image with 1 pixel height the background-image of a div?


I have an image which is 1 pixel high and 600 pixels long, however when I set this image to be the background of a div, the image is not displayed. For example:

<div style="background-image:url(.images/goldSplitterMed.png); background-repeat:repeat-y"></div>

The repeat I think is irrelevant but I've just used it incase.

I've tried setting the width and heights but also to no prevail.

Is there anything else that could be stopping this image appear?

Thanks


Solution

  • As it is right now, your <div> has zero height because it has no content. Background images are not content ;)

    Either put something in there, or add a height to the CSS.