Computer >> Computer tutorials >  >> Programming >> CSS

Set background image as fixed with CSS


Use the background-attachment property to display the background image as fixed.

Example

You can try to run the following code to implement the background-attachment property −

<!DOCTYPE html>
<html>
   <head>
      <style>
         body {
            background-image: url("https://www.tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg");
            background-repeat: no-repeat;
            background-attachment: fixed;
            background-position: right top;
         }
      </style>
   </head>
   <body>
      <h1>Background Image</h1>
   </body>
</html>