Jump to content

image as background-image?


dina

Recommended Posts

This has happened to me several times too.

 

Change the following in your body tag

background-image: url('images/dark_pixel.jpg') repeat-x;

 

to

background: url(images/dark_pixel.jpg) repeat-x;

 

In other words don't add -image to background and remove the quotes.

 

Also there is no background image in your header css.

 

Hope this helps

 

[Mod Edit - I fixed the typo in the code line provided by virtual to avoid confusion]

Edited by Andrea
Link to comment
Share on other sites

Ok, thank you virtual, I have tried that but no luck. I'm literally sitting with my hands in my hair, because I'm working against time.

 

the only other thing that I can think of could be my DOCTYPE! is it right, could you please have a look at it.

 

 

thanx

Link to comment
Share on other sites

This has happened to me several times too.

 

Change the following in your body tag

background-image: url('images/dark_pixel.jpg') repeat-x;

 

to

background: url(images/dark_pixel.jp') repeat-x;

 

In other words don't add -image to background and remove the quotes.

 

Also there is no background image in your header css.

 

Hope this helps

 

There's a small typo here. It should be:

 

background: url(images/dark_pixel.jpg) repeat-x;

 

 

Can you give us a link or give us the full page code? That will help us better determine what the problem is.

Link to comment
Share on other sites

Oops, I saw that typo too in the reply. Hopefully Dina removed the quotes and the -image and did not copy and paste my typo.

 

Next step is to make sure that your CSS is calling the right image and that there isn't a typo in there too for example an underscore instead of a dash. As you can see from my mistake a lot of grief can come from a typo.

 

Susie is right, can you give a link to the page, much easier to identify the problem.

Link to comment
Share on other sites

the only other thing that I can think of could be my DOCTYPE! is it right, could you please have a look at it.

 

 

thanx

Even an incorrect doctype likely wouldn't cause any issues with your background image displaying. But to ensure the cleanest code possible, it's better to use a strict doctype, not transitional or loose.
Link to comment
Share on other sites

Got it,

You need to change this line of code

background: url('bipolar.gif') repeat-x;

to this

background: url(../bipolar.gif) repeat-x;

 

The reason for the error is that your CSS file is in a folder, so to call the image from your css file within the folder you need the ../ to tell the CSS to look outside its own folder.

If you keep your css file in one folder and your images in another images folder you would need to change this to but only when calling the image from the css file.

background: url(../images/bipolar.gif) repeat-x;

Link to comment
Share on other sites

...also, virtual is correct with his explanation re paths. I learned long ago that using absolute paths to the CSS and to anything out of the CSS saves a lot of problems down the road - then it does not matter what folder something is, it'll always be right.

Link to comment
Share on other sites

Try this.

Put your image file in the CSS folder and leave the code for the background image like this

 

background: url(bipolar.gif) repeat-x;

 

If it shows up on your page, then your problem is where you had previously put your image.

 

Read the following article which explains the difference between relative and absolute paths.

http://www.ibdhost.com/help/path/

Link to comment
Share on other sites

Hi, I have tried to upload my site/page onto the server with little success, so I'm bzy trying to sort that out.

 

The next big problem that I have is that none of my images are visible when I load my page from wamp. I have tried every image and in different div too.

Link to comment
Share on other sites

Thanks for sending me the files...

 

Basically, you have most things right. Looks like you have a good file structure worked out, and most of your code is correct. Three things though (basically, my comments are exactly what all of the other members above have been saying):

 

-- What editor were you using to save your default.php file? When I previewed it, I got some strange squiggly characters at the top of the page. Resaving it in dreamweaver fixed the issue.

 

-- Secondly, this line is incorrect in two ways: background-image: url(css/dark_pixel.jpg) no-repeat;

 

First off, you need to use "background:" rather than "background-image:". Secondly, keep in mind that your file paths are relative to whichever file you are currently in. So, since the CSS file you are working on is in the CSS folder, there is no need to add "css/" to the beginning of the file name. If you want to access an image file that is in the same folder as the css, just use "dark_pixel.jpg". If you want to access a image file within your images folder, you need to go up one level (moving out of the CSS folder), then into the images folder, and then select your image (so, in this case, "../images/dark_pixel.jpg")

 

So, to recap, in order to get this to work, you need to change line 23 in your css file to this: "background: url(dark_pixel.jpg) no-repeat;"

 

-- Also, at least when I preview the default.php file, I don't get any images to display because there aren't any -- in your css, the only image you are using is associated with the #logo div, and that doesn't appear on the page.

 

Hopefully that helps clear things up. You have some issues with your CSS layout, but I don't want to discuss those until you get the images issue sorted out first.

Link to comment
Share on other sites

thank you, I have read through everything, it sounds complicated, so I will have a look at it in the morning because it is late already.(22h15 here).

 

thank you for your effort to try and sort it out for me.

 

Have a good nights rest too.

 

thank you yet again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...