* {
outline: 1px solid;
}
div.example {
background: red;
}
.example.ex1,
.example.ex2,
.example.ex3,
.example.ex4,
.example.ex5,
.example.ex10 {
position: absolute;
}
span {
background-color: yellow
}
div.ex4 {
z-index: 2500;
}
.example.ex6,
.example.ex7,
.example.ex8,
.example.ex9 {
position: relative;
}
.ex8,
.ex9 {
top: 40px;
}
.ex9 {
width: 500px;
height: 500px;
}
.ex10 {
bottom: 0;
}
<div>im a block-level element, i have by default position:static</div>
<div class="example ex1">im a absolute element, i have position:absolute
<span>my parent has an absolute position i'm just an inline element</span>
</div>
<div class="example ex2">im a absolute element, i have position:absolute
<span>hm hm hm hm hm my parent has also position:absolute, if no top,left,bottom,right is defined than i will place my self in the normal document flow without looking to position:absolute elements, floated elementes, position:fixed elements, position, relative elements</span>
<span>if two or more position:absolute elements are in the same place without a stacking-order than is the one that was latest in document-flow who get higher stakcing-order</span>
</div>
<div>
<div>make</div>
<div>some</div>
<div>room</div>
<div>for example 3</div>
<div>for example 4</div>
<div>for example 5</div>
</div>
<div class="example ex3">Example 3</div>
<div class="example ex4">Example 4:: ex3, ex5 has no stacking order but ex4 does, autor-define stacking are higher than browser setted stackings</div>
<div class="example ex5">Example 5</div>
<div>
<div>make</div>
<div>some</div>
<div>room</div>
<div>for example 6</div>
<div>for example 7</div>
<div>for example 8</div>
</div>
<div class="example ex6">Example 6, i have position: relative</div>
<div class="example ex7">Example 7, i have position: relative<span>hm hm hm hm hm my parent has also position:relative, if no top,left,bottom,right is defined than i will place my self in the normal document flow</span>top
</div>
<div class="example ex8">Example 8, i have position: relative and bottom: 40px;<span>meaning i will move myself 40px away from the top where the document-flow woulkd place me</span>
</div>
<div class="example ex9">I have position:relative i'm also a block-element and have a width of 500px and an height of 500px; i also have top: 40px;
<div class="example ex10">i'm a block-level element with position:absolute inside of an element with position:relative i also have bottom: 0 so i place myself 0px away from the bottom line of my <b>nearest positioned ancestor</b> if i have no nearest positioned ancestor i take
the document root</div>
</div>