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
Want To Be A Web Master?
If you want to be a Web Master, you will have to host your web site with an ISP (Internet Service Provider).
MaximumASP offers seven different configurations of dedicated servers to meet your Windows and .NET hosting needs.
Hosted on our multi-tiered Enterprise Class network, these servers provide the performance, security and reliability
you need to host your high end web sites and applications.
Visit MaximumASP
|