liveBook · Manning

Position property

As explained in Tiny CSS Projects

The CSS position property specifies how an element is positioned in the document layout.

The position property controls how an element is placed in the document layout. Relative positioning establishes an ancestor for an absolutely positioned element, while absolute positioning removes that element from normal flow. section 9.5.1

Use these behaviors when layering or nudging interface elements:

  • Set a card container to position: relative so positioned descendants use it as their reference. section 9.5.1
  • Set a card face to position: absolute; top: 0 and left: 0 place it at the container’s top-left corner and remove it from normal flow. section 9.5.1
  • Use relative positioning with top, bottom, left, or right to adjust an element’s position relative to surrounding content. section 7.1.3

Stacking the faces of a virtual credit card

Give the card container relative positioning, then place its back face absolutely at top: 0 and left: 0. The back face can occupy the same area as the front and rotate during the flip effect. Apply this arrangement only where hover is supported; on devices without hover, show both faces together. section 9.0 section 9.5.1

How Tiny CSS Projects covers it

How deep it goes
Explains relative and absolute positioning, containing ancestors, normal-flow removal, sizing, and top-left offsets without surveying other position values.
Examples
Demonstrates stacked credit-card faces and a relatively repositioned drop cap.
What you can do after
Apply it via CSS to layer interface elements or fine-tune their placement relative to a container or surrounding text.
How it connects
Connects positioning with CSS Flexbox, CSS transforms, media queries, hover capability, and document flow.

Also explained in

Compare how 2 books explain position property →

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.