Background Attachment
Controls how the background responds to scrolling.
Widely available
This feature is well established and works across many devices and browser versions.
Chrome
Edge
Firefox
Safari
| Class | Style |
|---|---|
ba-f | background-attachment: fixed; |
ba-l | background-attachment: local; |
ba-s | background-attachment: scroll; |
Scroll
Initial value
The image will move with the content of the page.
Try scrolling through the image to see how it behaves.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<div class="o-auto ba-s bs-c ff-c fs-xxl fw-700 max-h-80 p-5 ta-c" style="background-image: url(/img/sea.jpg);"> London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall.</div>Fixed
The image will not move when the content is scrolled.
Try scrolling the page to see how it behaves.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<div class="o-auto ba-f bs-c ff-c fs-xxl fw-700 max-h-80 p-5 ta-c" style="background-image: url(/img/sea.jpg);"> London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall.</div>Local
The image will scroll with the content of the element.
Try scrolling through the image to see how it behaves.
London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill. London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall. Implacable November weather. As much mud in the streets as if the waters had but newly retired from the face of the earth, and it would not be wonderful to meet a Megalosaurus, forty feet long or so, waddling like an elephantine lizard up Holborn Hill.
<div class="o-auto ba-s bs-c ff-c fs-xxl fw-700 max-h-80 p-5 ta-c" style="background-image: url(/img/sea.jpg);"> London. Michaelmas term lately over, and the Lord Chancellor sitting in Lincoln's Inn Hall.</div>Using utility variants
Learn how to override existing utilities based on the user's screen size or other factors, such as hover states.
Targeting different viewports
You can combine responsive breakpoints like sm:ba-*, md:ba-*, lg:ba-*, and xxl:ba-* to allow targeting specific utilities in different viewports.
Targeting hover states
Alternatively, you can apply :hover by using h:ba-* utility to override elements and change their values when hovering over them.