...

View Full Version : div wont display background image



surreal5335
07-08-2011, 06:47 AM
I have done background-images a lot before without problem. But this time I have tried so many things but it wont load.

I put the same path into an <img> and it loads, so its not the path.

Here is the css I have tried:



.banner_image
{
background:url(images/logo.png);
background-position: left top;
background-repeat:no-repeat;
}




.banner_image
{
background-image:url(images/logo.png);
background-position: left top;
background-repeat:no-repeat;
}




.banner_image
{
background-image:url('images/logo.png');
background-repeat:no-repeat;
}


I have tried setting the height, width and border of my div to make sure the image has space to load into... it has plenty.

I checked the image in firebug, but it wont load there. Am I using the wrong syntax to call it?

I have tried putting the css directly into the div with the style and in an external css file. Both times firebug cant load the image.

What am I missing?

Sammy12
07-08-2011, 06:49 AM
try floating the div to the left.

also you should define a height and width for the div of the background.

---

http://i1114.photobucket.com/albums/k535/auroralight1/Untitled-6.png

you might also want to check to make sure the directories are the same for a stylesheet.

<link rel="stylesheet" href="style/global.css"/>

The global.css is in the "style" folder, which is one-up from the index.
Therefore a background must be stated as :



background: url('/directory/images/banana.gif') no-repeat top left;

surreal5335
07-08-2011, 08:27 AM
Thank you for the reply, the directory was the problem. I wonder why it worked loaded into an image?

Sammy12
07-08-2011, 08:39 AM
loaded into an image?

for index the path would be:


<img src="images/rada.gif"/>


for a stylesheet in a style folder for the same image:


.rada { background: url('/directoryname/images/rada.gif');


it has to do with the fact that the stylesheet is in a folder, while the index is in the directory.

DIRECTORY - IMAGES/STYLE/INDEX.PHP, if your in "style" you need to go back to directory --> to to image --> then choose your image.

well its working now so cheers to that!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum