Backgrounds
Utilities for controlling how a background image behaves when scrolling.
Class | Styles |
---|---|
bg-fixed | background-attachment: fixed; |
bg-local | background-attachment: local; |
bg-scroll | background-attachment: scroll; |
Use the bg-fixed
utility to fix the background image relative to the viewport:
Scroll the content to see the background image fixed in place
Use the bg-local
utility to scroll the background image with the container and the viewport:
Scroll the content to see the background image scroll with the container
Use the bg-scroll
utility to scroll the background image with the viewport, but not with the container:
Scroll the content to see the background image fixed in the container
Prefix a background-attachment
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="bg-local md:bg-fixed ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.