Im trying keep an element fixed within a container but the fixed element seems to be positioning itself according to the screen but not the parent element.
My code :
<div class="relative">
  <div class="absolute">
    <div class="fixed"></div>
  </div>
</div>
Css :
.relative{
  position: relative;
  height:800px;
  width: 400px;
  background: #000;
}
.absolute{
  height:60px;
  width: 60px;
  position: absolute;
  top:0;
  right:0;
  background: #ccc;
  -webkit-transform: translateZ(0); 
}
.fixed{
  height:20px;
  width: 20px;
  background: red;
  position: fixed;
  top:0;
  right:0;
}
I want the red box to be fixed inside the grey box . but now when i scroll the box scrolls and doesnt remains fixed.
See it live : http://codepen.io/undefinedtoken/pen/abhgc
 
     
     
     
     
     
    