liveBook · Manning

Absolute positioning

As explained in Tiny CSS Projects

Absolute positioning is a CSS positioning technique that removes an element from normal flow and positions it relative to a containing block established by a positioned ancestor.

Absolute positioning takes an element out of normal page flow, so it no longer reserves space there. Set `position: absolute` and use `top`, `left`, `right`, `bottom`, or `inset` to place it. Its position is calculated from the closest relatively positioned ancestor; without one, the page’s top-left corner is the reference point. section 9.5.1

Two details matter when placing an element:

  • With no offset set, it appears where it normally would, but still takes up no space in the flow. section 9.5.1
  • Without an explicit width, even a block-level element takes only the width it needs. A percentage width is calculated against the element it is positioned relative to. section 9.5.1

Layer the faces of a card

Give the card container `position: relative`. On hover-capable devices, set the back face to `position: absolute; top: 0; left: 0` to place it over the front. On devices without hover, show both faces instead. section 9.5.1

Keep mobile table headers available

A narrow checkout table can move its `thead` offscreen with `position: absolute; left: -9999rem`. Unlike `display: none`, this hides the headers visually without removing their information from assistive technologies. Cell labels can then come from `data-name` attributes. section 8.3.1

Listing 9.22 Positioning the back over the front
@media (hover: hover) {
  .back {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(-180deg);     #1
  }
}

The media-query listing shows the offsets that stack a card’s back face over its front. section 9.5.1

Listing 8.17 Hiding the table headers
@media(max-width: 549px) {
  ...
  thead {
    position: absolute;
    left: -9999rem;
  }
}

The listing shows the offscreen positioning used for mobile table headers. section 8.3.1

How Tiny CSS Projects covers it

How deep it goes
Explains normal-flow removal, ancestor-based placement, unset offsets, and sizing effects through CSS declarations.
Examples
Shows an overlaid card back and a table header shifted offscreen while data-attribute labels identify mobile cells.
What it assumes
Assumes basic HTML and CSS editing while explaining normal flow, offsets, and relative ancestors in context.
What you can do after
Operate/configure it with CSS offsets to overlay card faces or hide table headers visually while retaining their information for assistive technologies.
How it connects
Connects absolute positioning to relative positioning, normal flow, responsive tables, media queries, and assistive technologies.

Also explained in

Compare how 2 books explain absolute positioning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.