background-attachment

Class Description

bg-fixed

Sets background-attachment: fixed. Background stays fixed during scroll.

CSS Rules

.bg-fixed {
  background-attachment: fixed;
}

Usage

<element class="bg-fixed" />

Responsive

Prefix .bg-fixed utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:bg-fixed" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="bg-fixed:hover" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="bg-fixed:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before bg-fixed::before" />

<element class="content-after bg-fixed::after" />
.bg-fixed Sets background-attachment: fixed. Background stays fixed during scroll.

bg-local

Scrolls the background image with the element's contents.

CSS Rules

.bg-local {
  background-attachment: local;
}

Usage

<element class="bg-local" />

Responsive

Prefix .bg-local utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:bg-local" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="bg-local:hover" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="bg-local:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before bg-local::before" />

<element class="content-after bg-local::after" />
.bg-local Scrolls the background image with the element's contents.

bg-scroll

Sets background-attachment: scroll. Background scrolls with the element.

CSS Rules

.bg-scroll {
  background-attachment: scroll;
}

Usage

<element class="bg-scroll" />

Responsive

Prefix .bg-scroll utility with a breakpoint variant (e.g., md:) to apply styles at specific screen sizes (Supported breakpoints are xm through 2xl).

<element class="md:bg-scroll" />

States

States are generated dynamically at runtime and always come last. Append a state like :hover or :focus to the end of the class. This works in conjunction with breakpoints .

Supported pseudo-classes: :hover, :active, :focus, :focus-visible, :focus-within, :target, :checked, :disabled, and :group-hover.

<element class="bg-scroll:hover" />

Group Hover Example

The :group-hover state applies styles when a parent element with the .group class is hovered.

<element class="group">
  <element class="bg-scroll:group-hover">...</element>
</element>

Pseudo-Elements

The ::before and ::after utility classes are supported too. Granted that you add the mandatory content-before or content-after class in order for them to work.

<element class="content-before bg-scroll::before" />

<element class="content-after bg-scroll::after" />
.bg-scroll Sets background-attachment: scroll. Background scrolls with the element.