Position Offset Properties

There are four offset properties: top left bottom right.

Positive offset values push the element sides inwards, towards the center of the containing block. Negative values push the sides outwards, away from the containing block sides. The values are always relative to the corresponding edges of the containing block.

The entire element, including its margins, paddings, borders, etc. and the space they occupy, is 'moved'.

An elements width and height can be limited using min-width max-width along with min-height max-height

(Note: all the examples have a parent box with position: relative and a child box with position: absolute)

What can happen with position: absolute

You might expect to see this:

but when you change the child element's position to 'absolute' you see this:

What happened to the containing block?? If the element has an explicit size and the containing block has no other content, setting the element position to absolute will cause the containing block to collapse as its 'content' (the sized element) has now been removed (taken out of normal flow) and the container, for all intents and purposes, is empty.

To make use of implicit sizing (see below) for the purpose of positioning, the containing block must have a size, if it doesn't the % values are meaningless and the element will collapse.

Examples

Initial Position
top: 0 left: 0
Move to bottom, right
top: 50% left: 50%
Move to bottom, right with a margin
top: 50% left: 50% margin: 1vw
Move to top, right
top: 0 right: 0
Move to bottom, left
bottom: 0 right: 50%
Negative Offsets
top: 50% bottom: -2em left: 75% right: -7em
Fill Left Side
width and height not explicitly set
top: 0 bottom: 0 left: 0 right: 50%
Fill Left Side, Explicit Sizing with Padding
width and height are explicitly set, padding added
width: 50%, height: 50% padding: 2vw top: 0 bottom: 0 left: 0 right: 50%
Fill Left Side, Implicit Sizing with Padding
width and height are not explicitly set, padding added
padding: 2vw top: 0 bottom: 0 left: 0 right: 50%
Enforce a Size
top: 10% bottom: 20% left: 50% right: 10% min-width: 10vw min-height: 20vw;
Without Enforcement
without min-width/height
top: 10% bottom: 20% left: 50% right: 10%
Enforce while respecting container
min-width: 10vw; height: auto top: 10% bottom: auto left: 50% right: 10%