Skip to content

Backgrounds

Background Attachment

Utilities for controlling how a background image behaves when scrolling.

Quick reference

ClassDescription
bg-fixedbackground-attachment: fixed
bg-localbackground-attachment: local
bg-scrollbackground-attachment: scroll

Basic usage

Fixed

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

The science

March 9th, 2023 · 14 min read

General Relativity states that space and time are fused and that nothing can travel faster than the speed of light. General relativity also describes how mass and energy warp spacetime – hefty objects like stars and black holes curve spacetime around them. This curvature is what you feel as gravity and why many space-faring heroes worry about “getting stuck in” or “falling into” a gravity well.

In some respects the force was electricity, but it was of a higher energy order, containing inherent magnetic properties in a complete union of a kind only vaguely suggested by the term “electromagnetic,” in which the two forces involved are more or less mutually exclusive, the one giving rise to the other.

html
<div class="bg-fixed ..."></div>

Local

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

The science

March 9th, 2023 · 14 min read

General Relativity states that space and time are fused and that nothing can travel faster than the speed of light. General relativity also describes how mass and energy warp spacetime – hefty objects like stars and black holes curve spacetime around them. This curvature is what you feel as gravity and why many space-faring heroes worry about “getting stuck in” or “falling into” a gravity well.

In some respects the force was electricity, but it was of a higher energy order, containing inherent magnetic properties in a complete union of a kind only vaguely suggested by the term “electromagnetic,” in which the two forces involved are more or less mutually exclusive, the one giving rise to the other.

html
<div class="bg-local ..."></div>

Scroll

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

The science

March 9th, 2023 · 14 min read

General Relativity states that space and time are fused and that nothing can travel faster than the speed of light. General relativity also describes how mass and energy warp spacetime – hefty objects like stars and black holes curve spacetime around them. This curvature is what you feel as gravity and why many space-faring heroes worry about “getting stuck in” or “falling into” a gravity well.

In some respects the force was electricity, but it was of a higher energy order, containing inherent magnetic properties in a complete union of a kind only vaguely suggested by the term “electromagnetic,” in which the two forces involved are more or less mutually exclusive, the one giving rise to the other.

html
<div class="bg-scroll ..."></div>

Released under the Apache 2.0 License.