473,657 Members | 2,572 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 7595
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
7257
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, thus making I look like one high image in there. When validating it, I get this error: there is no attribute "BACKGROUND" The validators also tell me there are no "HEIGHT" or
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, Background is not a member of the SystemColors class, and it is not
2
2519
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 transparent gif image I can't use LinkButtons over this image. The string that I'm using now is: <body background="BMP/Header.gif" MS_POSITIONING="GridLayout"> Maybe I should use something else in place of GridLayout?
8
2225
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 in this format in html output:
1
3881
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" . <td background="images/nav1bg.gif" onMouseOver="this.className='over'" onMouseOu 2) Line 223, Column 74: there is no attribute "BACKGROUND" .
1
1870
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 presents the results page. Basically, on the first webpage (html) user chooses which programs are to be executed, and then an asp script runs the programs on the server. The problem is that I don't know how to run these programs in
0
2045
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 text, how to do it? wx.FULL_REPAINT_ON_RESIZE style on MDI parent frame would help a little, but I would also need to call self.Layout() (and I still can erase the text moving child frame over the text...) #!/usr/bin/env python # -*- coding:...
7
2228
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. Furthermore, I want it to obey the same positioning rules as a normal div. And (like a background image) I don't want the presence of this div to shift other elements over. Cheers,
1
2027
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 additional code. Is it possible to pass in the name of a sub at runtime instead of hard-coding it? To do this I would replace onDoWork and onProgressChanged below and use (Byval onWorkSub as SomeKindOfObject?, Byval onProgressChangedSub as...
0
8425
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.