<div class="relative">
Relative
<div class="absolute top">Absolute to parent</div>
<div class="absolute right bottom">Absolute to parent</div>
</div>
<div class="absolute right free">Absolute to document</div>
<div class="fixed right top">Fixed to viewport</div>
<div class="fixed right bottom">Fixed to viewport</div>
index.html
div {
padding: 1rem;
margin: 1rem;
border-radius: 1rem;
width: 50vw;
background-color: lightgrey;
}
.relative {
position: relative;
height: 150vh;
}
.absolute {
position: absolute;
background-color: blue;
}
.fixed {
position: fixed;
background-color: springgreen;
}
.left {
left: 1rem;
}
.right {
right: 1rem;
text-align: right;
}
.top {
top: 2rem;
}
.bottom {
bottom: 2rem;
}
.free {
top: 10rem;
background-color: yellow;
}
.relative .absolute {
color: white;
}