473,503 Members | 12,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

8 New Member
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
3 7590
soulmach
8 New Member
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 Recognized Expert Moderator MVP
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
drhowarddrfine
7,435 Recognized Expert Expert
:fixed has never worked in IE6. There are js workarounds for position:fixed and css workarounds but I don't know about background image fixes. Here's a CSS solution for position:fixed if it helps at all.
Mar 23 '07 #4

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

Similar topics

17
7235
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
461
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
2516
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
2219
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
3874
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
1860
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
2040
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
2225
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
2012
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
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
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...
1
7017
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
7470
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...
0
5604
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.