bg-fixed : Tailwind CSS background attachement class

The bg-fixed class sets the background image of an element to remain fixed in place, even when the page is scrolled.


bg-fixed (Fixed Background)

The bg-fixed class sets the background image of an element to remain fixed in place, even when the page is scrolled.

Example Usage

html
<div class="bg-fixed bg-cover bg-blue-500 h-48 w-full text-white">
Fixed Background
</div>

Preview

Fixed Background

How to Use

Add the bg-fixed class directly to your HTML element:

html
<div class="bg-fixed">
<!-- Your content here -->
</div>

Responsive Usage

Use Tailwind's responsive prefixes to apply bg-fixed at specific breakpoints:

html
<div class="sm:bg-fixed md:bg-fixed lg:bg-fixed">
Responsive element
</div>
  • sm:bg-fixed — applies from 640px and up
  • md:bg-fixed — applies from 768px and up
  • lg:bg-fixed — applies from 1024px and up

Customization

You can extend or override this utility in your tailwind.config.js. See the Tailwind CSS documentation for details on customizing your theme.

Windframe is an AI visual editor for rapidly building stunning web UIs & websites

Start building stunning web UIs & websites!

Build from scratch or select prebuilt tailwind templates