two background images in the same div

They have: 426 posts

Joined: Feb 2005

Im just getting the hang of this css based layout business, and what ive realised is how important the doctype actually is when trying to make layouts the same in different browser and using the position relative and absolute properly....thanks megan you seem to be a css layout master...!!!

But im having a problem. How can i give one div two background images, one aligned to the left and one aligned to the right. It doesnt seem to work, maybe the second background declaration overrides the first???

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

You can't - multiple background images aren't yet supported by all browsers. Actually, I'm not even sure if that's in the spec yet. It is something web designers have been asking for for ages though. Safari does support multiple background images but none of the other browsers do.

What you need to do is find a way to work around this, either by putting one of the background images on another element or nesting a div.

I'm glad you're finding my advice to be useful Smiling

greg's picture

He has: 1,581 posts

Joined: Nov 2005

You could take both background images and make ONE image with them, then use that image.

They have: 426 posts

Joined: Feb 2005

Ah yes, nested divs setting padding and margin to 0 you wouldnt even notice......good thinking!

demonhale's picture

He has: 3,278 posts

Joined: May 2005

Use that single dive, put two divs inside, assign a BG for the first div inside and one for the other... it will wok as it is often done in sites with curved or stylized edges...

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.