Background Attachment Property


The background-attachment property specifies whether a background image is fixed with regard to the viewport or scrolls along with the containing block.

Syntax

background-attachment: scroll|fixed|local|inherit;

Values

  • Scroll : If specified, the background image scrolls with the element.
     body {
       background-image: url("img/fl/css/bg.jpg");
       background-attachment: scroll;
       }
    
  • fixed : If specified, the background image does not scrolls with the element.
     body {
       background-image: url("img/fl/css/bg.jpg");
       background-attachment: fixed;
       }
    
  • inherit : Takes the same specified value as the property for the element's parent.
     body {
       background-image: url("img/fl/css/bg.jpg");
       background-attachment: inherit;
       }
    

Share this article on