473,394 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

CSS "background-position: fixed;" problem, workaround with JS?

Hello forum friends. I performed a search on this topic, but I couldn't find anything useful. I wasn't really sure what to search.

First I'll state what I am trying to do. I recently agreed to make a site for a friend. It's good practice for me. The site will have (among other things) a biography. I told him to look at Zen Garden and find some layouts, and I'd see what I can do. His favorite layout for Biography is:

http://csszengarden.com/?cssfile=htt.../zengarden.css

Only heres the kicker, we want the layout centered. I realize from researching this zen garden layout, that centering this particular layout is not possible with CSS alone. Reason being, fixed backgrounds are relative to the viewport and not the containing element. I found that this is not a bug, but is (understandably) a W3C standard spec. In most cases, a fixed background relative to the viewport is desirable, but not in my case. In a Google frenzy, I also found that using "background-position: fixed" relative to the containing element will most likely be available in CSS3 (I cannot remember my sources on this), but at this moment these options are far from realization.

Finally My Question:
Is there an unobtrusive workaround with JavaScript which can simulate fixed background positioning relative to the containing element? Or, I suppose I could say, is there a script which could cause the layout above to work when centered, without breaking the page when scripting is turned off?

I understand JavaScript syntax, and when I study code by constantly referring to the W3Schools reference I can eventually understand most of it; however, I am still very new to DOM objects, and the properties and methods of each.

I hope I made this question understandable. I wasn't sure how to word it.

Thanks!
Mar 22 '07 #1
2 2175
I would like to correct above where I said "background-position: fixed" I did mean, "background-attachment: fixed".

Nonetheless, I actually found a work-around for this, which is not the best but it works. I just made the image the size of the containing element, which in this case isn't very large. Then I used "background-position: 50% 0;" which did exactly as planned.

A big bummer though. I've had IE7 for a while now, and I decided to download IE6 for testing reasons. I tested this layout in IE6 and it appears to be broken, even on the Zen Garden layout. I will instead be requiring an IE6 workaround, which I know I can find eventually.

If you would like to help me with this, I would be honored :-D

Thanks!
Mar 22 '07 #2
acoder
16,027 Expert Mod 8TB
You'll probably find better help on this in the HTML/CSS forum, but I'll copy it over instead of completely moving it in case we can have both a CSS solution and a JS workaround. I think, though, that you'd prefer the former over the latter.
Mar 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Torbjørn Pettersen | last post by:
I've got a table where I want some of the cells to use a background image. The cells have variable height, so I am using an image with a rather small height to fill up the background of the cells,...
4
by: Charles Law | last post by:
When displaying the Color Picker for a web page (in the VS IDE), Background is listed on the System Colors tab. Also, Color.FromName("Background").IsNamedColor returns True. However,...
2
by: Just D. | last post by:
Who knows what should we include into aspx file to show some image as a background picture but only once at the top of the page? I don't want to add the Image control because even if it uses a...
8
by: Maxwell2006 | last post by:
Hi, Using ASP.NET 2.0, I have this tag in my asp page: <td runat =server background="~/Images/Header2.gif">&nbsp;</td> The problem is when I run the page, the server side TD tag renders...
1
by: Miggiddy79 | last post by:
Does any body know how to fix this. I am trying to validate these html codes through the markup validation. I have 5 error messages: 1) Line 114, Column 15: there is no attribute "BACKGROUND" ....
1
by: wstach | last post by:
Hi, I'm using Windows XP, IIS & ASP to develop a web service that executes several programs (command line .exe files) on a server, shows next webpage with info on progress in execution, and...
0
by: dazzler | last post by:
How do I add "background text" into MDI parent frame, the text will be now erased if I move the MDI Parent frame, or I can also erase text with moving MDI Child frame, need to somehow refresh the...
7
by: chardish | last post by:
Hello, Is it possible to make a div part of the "background"? In other words, I want it to always render if that part of the screen is showing, but not create scrollbars under any circumstances....
1
by: Infog | last post by:
I am trying to code a simple background workers class without needing to use the backgroundworker object on a form. This would allow me to use a background worker in any class without writing much...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.