Skip to main content

Layout

Z-index

While not a part of the grid system, z-indexes play an important part in how the components overlay and interact with one another.

View page source on GitHub

Several components use z-index, the CSS property that helps control layout by providing a third axis to arrange content. felt-css uses Bootstrap's z-index scale, designed to properly layer navigation, tooltips and popovers, modals, and more, so its components layer the same way next to Bootstrap's or your own.

These higher values start at an arbitrary number, high and specific enough to ideally avoid conflicts. We need a standard set of these across the layered components—tooltips, popovers, navbars, dropdowns, modals—so we can be reasonably consistent in the behaviors. There's no reason we couldn't have used 100+ or 500+.

We don't encourage customization of these individual values; should you change one, you likely need to change them all. Unlike Bootstrap, felt-css has no variables for them: they are plain values in felt.css.

Layerz-indexBootstrap
.dropdown-menu1000$zindex-dropdown
.sticky-top, .sticky-bottom (and their breakpoint variants)1020$zindex-sticky
.fixed-top, .fixed-bottom1030$zindex-fixed
.offcanvas-backdrop1040$zindex-offcanvas-backdrop
.offcanvas1045$zindex-offcanvas
.modal-backdrop1050$zindex-modal-backdrop
.modal1055$zindex-modal
.popover1070$zindex-popover
.tooltip1080$zindex-tooltip
.toast-container1090$zindex-toast

Within components#

To handle overlapping borders within components (e.g., buttons and inputs in input groups, list group items, pagination links), felt-css uses low single digit z-index values of 1, 2, and 3 for default, hover, and active states. On hover/focus/active, a particular element is brought to the forefront with a higher z-index value to show its border over the sibling elements. Validation tooltips use 5, the carousel's controls 1 and its indicators 2, as in Bootstrap.

Seams in the felt look#

The felt look draws its seams, stitch rows and felt details with ::before and ::after, layered with small values inside the piece they belong to, never above the scale above:

  • The seam of a sewn piece (a card, an alert, a modal, a list group…) is its ::after at z-index: 3, over the piece's content but under anything positioned higher; the seams of buttons and pagination links stay at auto.
  • Photos lie on top of the felt: card images are lifted to 4, so a card's seam runs underneath them, and .card-img-overlay to 5, above its image.
  • A list group isolates its stacking (isolation: isolate), so its seam can sit above the hovered and active items (1 and 2) without reaching out of the list.
  • The seam of a .fixed-top or .fixed-bottom navbar goes under the bar's content (0).
  • In a carousel, the felt corners holding the photo are at 3 and their shadow at 2: above the slides (1 while they cross-fade) and level with the indicators; they let clicks through to the controls.

If you position elements of your own inside felt pieces, keep them under 3 to stay below the seam, or lift them to 4 to lie on top of it, like the card images.