...

View Full Version : Fixed Background in table



kestrel7
09-23-2002, 04:42 PM
I want to be able to set a fixed background (no repeat) as a background to a particular table using something like this in the style sheet...


TABLE.main {
background-image: url("img_name.gif");
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
}


However, this seems only to work in Opera. Is it possible to get this to work in IE? Thanks in advance :)

Bosko
09-23-2002, 06:44 PM
If you use code yes,not with CSS since IE doesn't support fixed positioning (not for elements,nor for backgrounds).
I don't exactly understand what the code is suposed to do,Mozilla and Konqueror render no background when I use it.If you want a single centered image then this code will work in all W3C compliant browsers (Opera,Mozilla,Konqueror):


background-image: url("img_name.gif");
background-position: center center;
background-repeat: no-repeat;


You can find alot of information on backgrounds with CSS (positioning,repeating etc.) here: http://cgi.din.or.jp/~hagi3/JavaScript/Mozilla/SampleList.cgi?fmt=html .

kestrel7
09-25-2002, 09:26 AM
Thanks for your help Bosko,

To clear up: I am trying to have a background that remains fixed in a particular position (top, center... etc) when the user scrolls the page.

In IE this can be done for the entire page background using..


<body background='img_name' bgproperties=fixed>


The problem is, I want to do this only for a table using the CSS I sent in my previous post. While this code works precisely as I want in Opera it does not seem to work in either IE or Mozilla (the background image appears but is not fixed instead it scrolls with the page). Is there any way in which I can fix this?

If I understand your reply correctly, then there is a way using some code (rather than CSS only). Could you point me in the right direction for this? Is PHP suitable to accomplish this or would it need to be something client-side? Any ideas on how to write the code would also be greatly appreciated ;)

Bosko
09-25-2002, 05:30 PM
I tested your code in Opera and I see what you mean,your code works fine in Mozilla and Konqueror too,only they render the image in the center of the whole page (and not of the table).
According to http://www.w3.org/TR/REC-CSS1#background-position Mozilla and Konueror have the correct behaviour,so you will have to use a script for this.

kestrel7
09-26-2002, 05:14 PM
Thanks again Bosko,

Is it possible to do in php or will I need javascript? Any ideas on how (algorithmically I mean) I would accomplish this with a script?

As usual, any help greatly appreciated!

adios
09-26-2002, 05:19 PM
Some light reading: :cool:

http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html

Bosko
09-26-2002, 09:33 PM
That links confirms what I said:

Unfortunately, not every browser supports all of CSS1, and only those browsers which fully and completely support CSS1 will get this right. According to my tests, that's Netscape 6.x (which also means Mozilla 0.8 and later), Konqueror 3.0, and Internet Explorer 5.x for the Macintosh.

ccording to CSS, any background image that is "fixed" using background-attachment: fixed; is fixed with respect to the viewport-- not the element with which the image is associated.

Btw,that site does not work in Opera.

I'll see if I can make a script to emulate this behaviour in Mozilla.

kestrel7
09-26-2002, 11:54 PM
WOW! Thanks for the great help guys :thumbsup:

The light reading really did the trick! I think I finally got it (thanks for your persistance Bosko)

In the process, I also think I gained some more respect for Netscape which I thought was absolutely crap till about 10 mins ago!

The demo page above seemed to work fine for me in Netscape 6.1, Mozilla 1.1a as well as Opera 6.05 (all Win)... the only one where the fixed background had no effect was IE 6. Will check it out in Linux soon, but don't forsee any probs.

Thanks for the great help!

Bosko
09-27-2002, 03:10 PM
No problem.

Btw,there shouldn't be any diference between Mozilla under Windows and Linux,it's the same.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum