Position fixed within overflow hidden parent - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

Position fixed within overflow hidden parent

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.parent {<!-- w  w  w .  ja  v  a2 s  .com-->
   position:relative;
}

.sub-parent {
   position:absolute;
   width:321px;
   right:0;
   top:0;
   height:251px;
   overflow:auto;
   bottom:0;
   background:yellow;
   z-index:2;
}

.parent .child-3 {
   position:fixed;
   right:0;
   top:6px;
   color:Chartreuse;
   z-index:11
}
</style> 
 </head> 
 <body> 
  <div class="parent"> 
   <div class="sub-parent"> 
    <div class="child-1"> 
     <h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus s</h1> 
    </div> 
    <div class="child-2"> 
     <h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus s</h1> 
    </div> 
   </div> 
   <div class="child-3"> 
    <h1>Lorem ipsum</h1> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials