<div class="container">
  <h1>Static Positioning</h1>
  <div class="A">
    <h1>A</h1>
  </div>
  <div class="B">
    <h1>B</h1>
  </div> 
  <div class="C">
    <h1>C</h1>
  </div>
</div>

<div class="container">
  <h1>Relative Positioning</h1>
  <div class="A">
    <h1>A</h1>
  </div>
  <div class="B relative">
    <h1>B</h1>
  </div> 
  <div class="C">
    <h1>C</h1>
  </div>
</div>

<div class="container">
  <h1>Absolute Positioning</h1>
  <div class="A">
    <h1>A</h1>
  </div>
  <div class="B absolute">
    <h1>B</h1>
  </div> 
  <div class="C">
    <h1>C</h1>
  </div>
</div>

<div class="container">
  <h1>Fixed Positioning</h1>
  <div class="A">
    <h1>A</h1>
  </div>
  <div class="B fixed">
    <h1>B (fixed)</h1>
  </div> 
  <div class="C">
    <h1>C</h1>
  </div>
</div>

<div class="container scrollable">
  <h1>Sticky Positioning</h1>
  <div class="A">
    <h1>A</h1>
  </div>
  <div class="B sticky">
    <h1>B (sticky)</h1>
  </div> 
  <div class="C">
    <h1>C</h1>
  </div>
</div>
*{
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body{
  width: 100%;
}

h1{
  margin-bottom: 20px;
}
.container{
  position: relative;
  background: #11698e;
  color: #f8f1f1;
  width: 500px;
  height: 500px;
  margin: 50px 0;
  padding: 20px;
}

.A, .B, .C {
  background: #19456b;
  color: #f8f1f1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 150px;
  height: 100px;
}

.B {
  background: #16c79a;
}

.relative {
  position: relative;
  top: 40px;
  left: 30px;
}

.absolute {
  position: absolute;
  top: 10px;
  right: 0px;
}

.fixed {
  position: fixed;
  top: 20px;
  right: 30px;
  z-index: 2;
}
.scrollable {
  height: 1000px;
}
.sticky {
  position: sticky;
  position: -webkit-sticky;
  top: 20px;
  right: 30px;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.