CSS and bg images

disaster-master's picture

She has: 2,154 posts

Joined: May 2001

What is the best way to do background images when using CSS? Should I put the bg image in the style sheet or put it in the body tag? Or both?

Reason I am asking is, I have it in my style sheet now but when I do a preview in dreamweaver it doesn't show up. It shows up online though. And when I put the bg image in the body tag and in the style sheet at the same time it doesn't show up either. (offline) And when I put it in the body tag it doesn't show up at all. ARG!!

I am too lazy to go surfing for the answer right now so if some kind soul wants to help out a poor old lady *cough cough* she would be most grateful. Wink

Busy's picture

He has: 6,151 posts

Joined: May 2001

I dont think I've ever used a background image of late using CSS.
But I always use CSS for table cell (td) backgrounds.

Since CSS doesnt have wide support yet, I see it as a perference, not a standard, I suppose its good practice for when/if its ever supported (or replaced, you just never know).

CSS makes it easier to change, so go with that Smiling

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

The background image in CSS does have pretty good support, all the way back to NS 4.7. If I use a background image, I always put it in my stylesheet since if I want to change it, I can do it once and not on every page. I also like how you can control the tiling better in a stylesheet.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

I use css for bg's now as mairving says the titling is easier to control and easier to change if needed.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

you will find you have problems with offline viewing if you don't have a virtual server set up on your machine, or if you use root urls for your image location.

Brooke's picture

She has: 681 posts

Joined: Feb 1999

Hey you guys

I was doing a search and it seems like you guys might know the answer to this one.

I have a background that I want to put in a table cell. I do not want the background to repeat.

I am using dreamweaver and I am using templates (they are kind of like ssi's.)

I have this code in the main template:

And this code in the page:

You can see the page at:
http://www.cataluna.com/clients/transwest/TTE/auto.html

Thanks!

Brooke

They have: 447 posts

Joined: Oct 1999

what's the problem?

Brooke's picture

She has: 681 posts

Joined: Feb 1999

I am sorry, I didn't even say. Basically it is not working!

Any ideas?

Brooke

Busy's picture

He has: 6,151 posts

Joined: May 2001

instead of a.type1:body just use .type1
was that cut and pasted or just typed out? looks like your missing a '(' around your background image source, which should be:
background-image: url(../TTE/images/stripe001.gif);
you missed out the 'url' bit

if the image is the same size as the table cell, you only need to use the background image: url part, dont need the fixed, centered, no repeat, like so:

.type1 {
background-image: url(../TTE/images/stripe001.gif);
}

Brooke's picture

She has: 681 posts

Joined: Feb 1999

Thank you for responding. I tried that and several variations and it is still not working.

Any more ideas?

Brooke

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

type="text/css">
.type1 {
background-attachment: fixed;
background-image: url(images/stripe001.gif);
background-repeat: no-repeat;
background-position: center center;
}
//-->

And this code in the page:

I don't know why you're going up a directory and back down for the images? There is no pseudo-class called :body. center center won't work for Netscape 4.x, it will always be top left. And you HAVE TO use the period infront of a class if you're not specifying an element.

either:

td.type1

or:

.type1

Anyway, if you use the code above it works fine. The HTML part is right.

Brooke's picture

She has: 681 posts

Joined: Feb 1999

You are a genious!! Thank you so much.

The reason why I am taking the image back a directory is because of the template - it's in a different place and it needs to be!

Thank you sooooooo much!

Brooke

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

ah, gotcha. well glad it works. It's always the little stuff that trips us up, lol.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.