Tailwind CSS - Background Attachment



Tailwind CSS Background Attachment is a utility that specifies the behavior of the background image when scrolled.

Tailwind CSS Background Attachment Classes

The following is the list of Tailwind CSS Background Attachment Classes that are used to set the scrolling behavior of background images.

bg-fixed background-attachment: fixed;
bg-local background-attachment: local;
bg-scroll background-attachment: scroll;

Functionality of Tailwind CSS Background Attachment Classes

  • bg-fixed: This class is used to fix the background image relative to the viewport and disable it from being scrolled.
  • bg-local: This class enables the background image to be scrolled with the container and the viewport.
  • bg-scroll: This class enables the background image to be scrolled with the viewport, but not with the container.

Tailwind CSS Background Attachment Examples

The following example will illustrate the different utility of Background Attachment Classes.

Setting Background Fixed

The below example illustrates the use of bg-fixed class.

Example




    



    

Tailwind CSS Background Fixed Class

HTML is a Standard Markup language for web pages. HTML stands for HyperText Markup Language and is used to create content and structure of any web page. If you think of the human body as a web page then HTML is the skeleton of the body. It is the building block of web pages.

HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard HTML specification which was published in 1995. Aim of this tutorial is to make you HTML expert by covering each tag and attribute's example codes.

Setting Background Local

The below example illustrates the use of bg-local class.

Example




    



    

Tailwind CSS Background Local Class

HTML is a Standard Markup language for web pages. HTML stands for HyperText Markup Language and is used to create content and structure of any web page. If you think of the human body as a web page then HTML is the skeleton of the body. It is the building block of web pages.
HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard HTML specification which was published in 1995. Aim of this tutorial is to make you HTML expert by covering each tag and attribute's example codes.
HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard HTML specification which was published in 1995. Aim of this tutorial is to make you HTML expert by covering each tag and attribute's example codes.

Setting Background Scroll

The below example illustrates the use of bg-scroll class.

Example




    



    

Tailwind CSS Background Scroll Class

HTML is a Standard Markup language for web pages. HTML stands for HyperText Markup Language and is used to create content and structure of any web page. If you think of the human body as a web page then HTML is the skeleton of the body. It is the building block of web pages.
HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard HTML specification which was published in 1995. Aim of this tutorial is to make you HTML expert by covering each tag and attribute's example codes.
HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard HTML specification which was published in 1995. Aim of this tutorial is to make you HTML expert by covering each tag and attribute's example codes.
Advertisements