Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Cape Town, South Africa
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Fixed Background in table

    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...
    Code:
    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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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):
    Code:
    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/JavaScri...t.cgi?fmt=html .

  • #3
    New Coder
    Join Date
    Aug 2002
    Location
    Cape Town, South Africa
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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..
    Code:
    <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

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New Coder
    Join Date
    Aug 2002
    Location
    Cape Town, South Africa
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    New Coder
    Join Date
    Aug 2002
    Location
    Cape Town, South Africa
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    WOW! Thanks for the great help guys

    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!

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    217
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No problem.

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •