View Full Version : putting 2 backgrounds in CSS


pixychik9
01-08-2006, 02:14 AM
the problem
OMG! I am Trying 2 put 2 backgrounds on my CSS and I dont know how 2 do it!!
why? you ask.
because one background repeats and the other one doesn't. and I want 2 put 2 puctures in my background.
background one needs to repeat-y
background two no repeat, needs to be centered horizontally and 40 pixels from the left

if you could possibly give me the codes for this it would be highly appreciated!!!!
thank you

djou
01-08-2006, 03:12 AM
You cannot assign two image backgrounds to one element. You would need to put the backgrounds in two different elements, like one in your body and one in a div that could contain your entire website.

For example:

body {background:url("yourbg") repeat-y}

#container {margin-left:40px;background:url("yourbg2") no-repeat center}

In your HTML:

<div id="container">everything that is inside your site</div>

pixychik9
01-09-2006, 09:55 PM
Thanx but where do i put those codes? and i also want the image 2 b fixed when scrolling.... Is that possible for both images 2 be fixed? and if so what code do i use?

Spid
01-10-2006, 12:10 AM
You cannot assign two image backgrounds to one element. You would need to put the backgrounds in two different elements, like one in your body and one in a div that could contain your entire website.

For example:

body {background:url("yourbg") repeat-y}

#container {margin-left:40px;background:url("yourbg2") no-repeat center}

In your HTML:

<div id="container">everything that is inside your site</div>


as dijou said

to keep the backgrounds fixed use background:url("yourbg2") no-repeat center in your css in the body div and the container div