Skip to main content

Helpers

Position

Use these helpers for quickly configuring the position of an element.

View page source on GitHub

Fixed top#

Position an element at the top of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.

<div class="fixed-top">...</div>

Fixed bottom#

Position an element at the bottom of the viewport, from edge to edge. Be sure you understand the ramifications of fixed position in your project; you may need to add additional CSS.

<div class="fixed-bottom">...</div>

For a bar at the bottom of a phone screen, add .pb-safe: it pads the bar by at least .5rem, and more where the device needs room for its home indicator (env(safe-area-inset-bottom)). Your page needs viewport-fit=cover in its viewport meta tag for the inset to be reported.

<nav class="navbar fixed-bottom pb-safe">...</nav>

A .navbar with .fixed-top or .fixed-bottom loses its rounded corners and side borders, so in felt it reads as a strip of felt sewn along its inner edge.

Sticky top#

Position an element at the top of the viewport, from edge to edge, but only after you scroll past it.

<div class="sticky-top">...</div>

Responsive sticky top#

Responsive variations also exist for .sticky-top utility. felt-css has no -xl/-xxl variants.

<div class="sticky-sm-top">Stick to the top on viewports sized SM (small) or wider</div>
<div class="sticky-md-top">Stick to the top on viewports sized MD (medium) or wider</div>
<div class="sticky-lg-top">Stick to the top on viewports sized LG (large) or wider</div>

Sticky bottom#

Position an element at the bottom of the viewport, from edge to edge, but only after you scroll past it.

<div class="sticky-bottom">...</div>

Responsive sticky bottom#

Responsive variations also exist for .sticky-bottom utility.

<div class="sticky-sm-bottom">Stick to the bottom on viewports sized SM (small) or wider</div>
<div class="sticky-md-bottom">Stick to the bottom on viewports sized MD (medium) or wider</div>
<div class="sticky-lg-bottom">Stick to the bottom on viewports sized LG (large) or wider</div>