# Background attachment

> Utilities for controlling how a background image behaves when scrolling.

Source: https://www.zenplates.co/documentation/utilities/background-attachment/ (Utilities › Backgrounds)

| Class        | Properties                       |
| ------------ | -------------------------------- |
| `.bg-fixed`  | `background-attachment: fixed;`  |
| `.bg-local`  | `background-attachment: local;`  |
| `.bg-scroll` | `background-attachment: scroll;` |

## Usage

### Fixed

Use `.bg-fixed` to fix the background image relative to the viewport.

```html
<div class="bg-fixed bg-cover bg-center bg-gray-200"></div>
```

### Local

Use `.bg-local` to scroll the background image with the container and the viewport.

```html
<div class="bg-local bg-cover bg-center bg-gray-200"></div>
```

### Scroll

Use `.bg-scroll` to scroll the background image with the viewport, but not with the container.

```html
<div class="bg-scroll bg-cover bg-center bg-gray-200"></div>
```

## Variants

By default, no responsive or hover-state variants are generated for background attachment utilities.

### Responsive

To include responsive variants like `.md:bg-fixed`, add `"background-attachment"` to the `$responsive-variants` variable in your theme's `_variables.scss` file when [recompiling your CSS](https://www.zenplates.co/documentation/customization/using-sass-source-files):

```scss
$responsive-variants: (
  // ...
  "background-attachment",
);
```

### Hover-state

To include hover-state variants like `.hover:bg-fixed`, add `"background-attachment"` to the `$hover-variants` variable:

```scss
$hover-variants: (
  // ...
  "background-attachment",
);
```
