Skip to content

Background Attachment

Utilities for applying background image's position on scroll.

Quick reference

ClassProperty
bg-attachment-localbackground-attachment: local;
bg-attachment-fixedbackground-attachment: fixed;
bg-attachment-scrollbackground-attachment: scroll;

Usage

Use the bg-attachment-{value} class for setup background image's position.


<div class="bg-attachment-fixed">
    <!-- ... -->
</div>

Applying conditionally

Breakpoints and media queries

You can also control the responsive breakpoint with variant class modifiers. For example lg:bg-attachment-scroll will be only apply on large screens size and above.


<div class="bg-attachment-fixed lg:bg-attachment-scroll">
    <!-- ... -->
</div>

Customization

Extend your theme

By default, the configuration provides a handful of general purpose background image's position utilities. You can easily filter the default scales using the Sass configuration.

@use "lasco" with (
    $extend: (
        "bg-attachment": (
            fixed
        )
    )
);

Disabled

You can easily disable the properties you don't need to use.

@use "lasco" with (
    $extend: (
        "bg-attachment": false
    )
);

Released under the MIT License.