View video tutorial
CSS Background Attachment
CSS
This specifies whether the background image should scroll or be fixed on the page.
CSS background-attachment
The background-attachment property specifies whether the background image should be scrollable or fixed to the page.
Example
body {
background-image: url('resources/images/dog-cartoon.png');
background-repeat: no-repeat;
background-position: right top;
margin-right: 50px;
background-attachment: fixed;
}
Click on the "Try it Now" button to see how it works.
Sample Code
Copy each file contents and paste it to your own project and run to see the final output
Example
body {
background-image: url('resources/images/dog-cartoon.png');
background-repeat: no-repeat;
background-position: right top;
margin-right: 50px;
background-attachment: scroll;
}
Click on the "Try it Now" button to see how it works.