CSS Attributes Index Color and Background Attributes
Sets or retrieves whether the background image scrolls with the object’s content or is fixed.
CSS |
{ background-attachment: 'scroll' | 'fixed' } |
Script |
object.style.backgroundAttachment = sAttachment ] |
scroll |
Background image scrolls with the content. |
fixed |
Background image does not scroll with the content. |
The property is read/write with a default value of scroll; this attribute is not inherited.
This property may be set together with the other background properties using the background composite property.
Microsoft® Internet Explorer® 3.0 supports the background-attachment attribute, but only when it’s set through the background attribute.
The following examples demonstrate how to set an element’s background-attachment style attribute so that it does not scroll with the text. Both methods yield the same effect.
The sample below defines a background-attachment style attribute in an embedded stylesheet.
<style>
body {
background-image: url( sample.jpg );
background-repeat: no-repeat;
background-attachment: fixed }
</style>
The sample below uses inline event handlers to dynamically set an object’s backgroundAttachment property.
<body background="sample.jpg"
onload="this.style.backgroundAttachment "fixed'">
The below example shows an alternative method to set the background-attachment attribute, using the composite background property. This method achieves the same result.
Show me
BODY, currentStyle, HTML, runtimeStyle, style
background, background-color, background-image, background-position, background-repeat