[thelist] Brain-Fart on fixed Background

James Aylard webmaster at equilon-mrc.com
Tue Jul 10 10:26:16 CDT 2001


martin wrote:
> <style type="text/css">
> <!--
> body {  background-attachment: fixed; background-image:
> url(image.ext); background-repeat: no-repeat; background-position:
> center center}
> - -->
> </style>

    Better yet, use the shorthand background property instead:

<style type="text/css">
 <!--
  body {
   background: #ffffff url(image.gif) no-repeat fixed center ;
  }
 // -->
</style>

    The order above is:

background-color
background-image
background-repeat
background-attachment
background-position

    Keep in mind that you only need specify the particular properties that
you want, and can leave the others to their defaults. And FWIW, one benefit
of this approach is that IE 3 understands the shorthand approach, but it
does not understand the enumeration of individual background properties.
    Also, I warn against using the Microsoft-proprietary "bgproperties"
attribute on the body element, which someone suggested earlier. The style
sheet approach that I've indicated above covers all versions of IE that
otherwise support "bgproperties" (IE 3+), it's standards-compliant, and it's
cross-browser compatible (except that Netscape 4.x doesn't support the
background-attachment and background-position properties, either in the
enumerated or shorthand form).

James Aylard





More information about the thelist mailing list