Click to See Complete Forum and Search --> : fixed background


LadyDrake
01-20-2003, 07:36 PM
Hi, I'm new here and to html. I have seen on other sites where the bachground doesn't move the words and pics on the page scroll but not the background. Can someone tell me how this is done? Thanks

meow
01-20-2003, 07:52 PM
Not with HTML, but with CSS.

In your CSS file (or within style tags in HEAD):

body { background: url(path/to/pic.gif) fixed }
You may want to take a look at all the background properties. There's a lot of things one can do. ;)
http://www.w3.org/TR/REC-CSS2/colors.html#q2

LadyDrake
01-20-2003, 07:59 PM
Wow its that simple? Thanks a bunch.

meow
01-20-2003, 08:06 PM
It is that simple. :p

I used a poor example though. With CSS you can apply backgrounds to all elements, not only BODY. So you can really let yourself go. :D

bisqui
01-20-2003, 08:10 PM
add this to your css instead. It works in NS6 also. I don't think the other example does.

background-attachment: fixed;

bisqui
01-20-2003, 08:19 PM
oops, disregard that! Not thinking straight tonight.

LadyDrake
01-20-2003, 09:09 PM
So the CSS one will work with netscape, or is it just a IE thing? Oh and thanks for the link meow, ive been readin threw the stuff and have gotten some great ideas and answeres to other "how they do that?" questions.

bisqui
01-20-2003, 09:19 PM
yeah sorry. I thought he was using 'background-image' which just sets the image, instead of 'background' which can set any number of background properties. Again, I'm just kinda out of it tonight. Anyway, if you JUST want to set the 'fixed' property, you can use my first suggestion.

meow
01-20-2003, 09:20 PM
Both are CSS and both will work in all modern browsers. It's just two ways of saying the same thing.

CSS often has long property names. The one I suggested, "background", is what's called a shorthand property and it allows you to set all background properties at the same time.

To make the other method work you would also have to add 'background-image'. So these two rules are equal:

p { background: url(path/to/pic.gif) fixed }
p { background-image: url(path/to/pic.gif); background-attachment: fixed }

<EDIT>
Oops! We posted at the same time but you were faster. :D

aderouin
01-21-2003, 11:55 AM
You could do this:

<body bgproperties="fixed">

bisqui
01-21-2003, 12:34 PM
if anybody discovers a practical way of doing this in NS4.x, let me know!

welo
01-21-2003, 06:12 PM
Originally posted by bisqui
if anybody discovers a practical way of doing this in NS4.x, let me know!
I doubt anyone ever found a practical method of doing much in NS4. Just let it die.

One of my New Year's Resolutions this year was to halt all support of NS4 unless someone paid me at least 50% extra for the favor. I even went as far as burning it onto a disk just so I could break it at midnight. :D