Utilities for controlling how a background image behaves when scrolling.
<div class="bg-fixed ..." style="background-image: url(...)"></div><div class="bg-local ..." style="background-image: url(...)"></div><div class="bg-scroll ..." style="background-image: url(...)"></div>To control the background attachment of an element at a specific breakpoint, add a {screen}: prefix to any existing background attachment utility. For example, use md:bg-fixed to apply the bg-fixed utility at only medium screen sizes and above.
<div class="bg-local md:bg-fixed ...">
<!-- ... -->
</div>For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
By default, only responsive variants are generated for background attachment utilities.
You can control which variants are generated for the background attachment utilities by modifying the backgroundAttachment property in the variants section of your tailwind.config.js file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ backgroundAttachment: ['hover', 'focus'],
}
}
}If you don't plan to use the background attachment utilities in your project, you can disable them entirely by setting the backgroundAttachment property to false in the corePlugins section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ backgroundAttachment: false,
}
}