XML technologies / CSS / CSS Cookbook / Hacks, workarounds and troubleshooting / Fixing background images in Internet Explorer 6 for Windows
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
You want to fix background images in Internet Explorer 6 for Windows on elements other than body.
Solution
Use the JavaScript code described below to force the desired effect. First, copy this code into your document:
<head>
<script type="text/javascript" src="fixed.js"></script>
</head>The source code for the file fixed.js is available on Andrew Clover’s website.
Discussion
According to CSS 2, a background image fixed with the property background-attachment should not move when the page scrolls. Unfortunately, this property does not work correctly in any version of Internet Explorer for Windows.
Andrew Clover’s remarkable JavaScript workaround solves this problem simply by adding the JavaScript link to the document. The code recalculates the viewport position during scrolling and adjusts the background image accordingly.
See also
The recipe Fixing the background image for more information on fixed background images, and the CSS 2 specification for the property background-attachment.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln