The
background-attachment property is used to specify whether or not the background image scrolls with the document.
The possible values are.
| Properties | Description |
|---|
fixed | the image is fixed relative to the view-port |
scroll | the image is fixed relative to the document, and the two will be scrolled together (the default value) |
snippet
<html>
<head>
<style>
p {width:300px; height:250px; background-image: url(bg.jpg)}
</style>
</head>
<body>
<form>
<p style="background-attachment: fixed; overflow: fixed">
Commodi numquam adipisci sit consequatur vitae saepe beatae, vero sit dignissimos
harum accusamus fuga iusto facilis expedita omnis beatae, dolorum perferendis harum
blanditiis nemo cumque dignissimos recusandae a aliquid, laboriosam</p>
<p style="background-attachment: fixed; overflow: scroll">
Commodi numquam adipisci sit consequatur vitae saepe beatae, vero sit dignissimos
harum accusamus fuga iusto facilis expedita omnis beatae, dolorum perferendis harum
blanditiis nemo cumque dignissimos recusandae a aliquid, laboriosam</p>
</form>
</body>
</html>