background-attachment Attribute | backgroundAttachment Property

DHTML, HTML, & CSS

background-attachment Attribute | backgroundAttachment Property


Sets or retrieves how the background image is attached to the object within the document.

Syntax

HTML{ background-attachment: sAttachment }
Scriptingobject.style.backgroundAttachment [ = sAttachment ]

Possible Values

sAttachment String that specifies one of the following values:
scrollBackground image scrolls with the object as the document is scrolled.
fixedBackground image stays fixed within the viewable area of the object.

The property is read/write with a default value of scroll; the cascading style sheets (CSS) attribute is not inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see dynamic propertiesInternet Link.

Remarks

This property can be set with the other background properties by using the background composite property.

Microsoft® Internet Explorer 3.0 supports the background-attachment attribute, but only when it's set by using the background attribute.

Example

The following examples use the background-attachment attribute and the backgroundAttachment property to set the background to "fixed", so that the background does not scroll with the text.

This example uses an inline style sheet to set the background to fixed.

Sample Code

<STYLE >
    BODY { background-attachment:fixed }
</STYLE>
</HEAD>
<BODY background="some.jpg">

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

This example uses inline scripting to set the background to fixed.

<BODY ID="oBdy" background="marble05.jpg"
onload="oBdy.style.backgroundAttachment = 'fixed'">

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
BODY, currentStyle, HTML, runtimeStyle, style

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.