CSS: Position Absolute

By Xah Lee. Date: . Last updated: .

What is Position Absolute

A Containing Block is the first parent element that has a position property value other than static. If none, it is relative to the Root Element.

Specify Offset

use one of:

  • top: length
  • bottom: length

and one of:

  • left: length
  • right: length

Example

aaa
bbb
ccc

Code

<div class="box-aa">
 <div>aaa</div>
 <div class="box-bb">bbb</div>
 <div>ccc</div>
</div>
.box-aa {
 position: relative;
}
.box-bb {
 position: absolute;
 top: 0.5rem;
 left: 2rem;
 outline: solid 2px red;
}

Example: Text Over Image

CSS Position

CSS Create Layer