HTML DOM backgroundAttachment Property
Complete Style Object Reference
Definition and Usage
The backgroundAttachment property sets whether a background image should be
fixed, or if it should scroll with the page.
Syntax
Object.style.backgroundAttachment=scroll|fixed
|
Tips and Notes
Tip: When adding a background-image to an element, you should also add a background-color.
The background-color will be used if the image
is unavailable.
Example
The following example sets a background-image to be fixed (will not scroll)
when clicking on a button:
<html>
<head>
<style type="text/css">
body
{
background-color="#FFCC80";
background-image:url(bgdesert.jpg);
}
p
{
color:white;
}
</style>
<script type="text/javascript">
function changeAttachment()
{
document.body.style.backgroundAttachment="fixed";
}
</script>
</head>
<body>
<input type="button" onclick="changeAttachment()"
value="Set background-image to be fixed" />
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
</body>
</html>
|
Try-It-Yourself Demos
Set a background-image to be fixed
Complete Style Object Reference
Whether you're new to XML or already an advanced user, the user-friendly views
and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to
meet your XML and Web services development needs from start to finish.
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- Support for Office Open XML (OOXML)
- Graphical WSDL editor & SOAP debugger
- Java, C#, C++ code generation
- And much more!
Download a fully functional free 30-day trial today!
|