I'm trying to creating a two-column layout for my website that consists of having fixed divs within one of the columns. Below is an overview, an image and my code. Any help on this will be greatly appreciated.
Overview:
- I have two elements that are both 100% in height. The
.user-navnav element and the.containerdiv element. - The
.user-navelement has fixed positioning, awidthof 75px and aheightof 100%. The.containerdivhas 100% ofwidth, 100% ofheightand -75pxmargin-left(to account for the.user-nav width). - Inside of the
.containerdiv, there are two moredivelements: the.viewportdivand the.right_paneldiv. (FYI: I wrapped the.containerelement around these 2divs because all the content inside the.containerdivis loaded dynamically with jQuery/Ajax.) - The
.right_paneldivis fixed positioned and has a width of 30% and a height of 100%. - The
.viewportdivhas a width of 70%. The.viewportdivcontains another 3divs, the.headerdiv, the.contentdivand the.footerdiv. All three of thosedivs should be 100% of the.viewportdiv. - Both the
.headerand.footerdivs inside the.viewportdivare fixed and have aheightof 50px. The.headerdivhas atop: 0pxapplied (to stick to the top) and the.footerdivhas abottom: 0pxproperty (to stick to the bottom). - The
.contentdivand its contents should be the only thing that scrolls on the page.
Issue:
The .viewport div seems to run longer than 70% and goes under the .right_panel div. I know that once you give a div position: fixed, its parent becomes the body. I believe that is where the issue lies.
How can I put a fixed position div inside of another div? Are there any other alternatives in creating a layout like this? What other approach should I take? Any suggestions would be helpful.
JSFiddle:** http://jsfiddle.net/mikerodriguez/709rcw8a/1/
Image of layout:

CSS
html{height: 100%;}
body{
margin: 0px;
height: 100%
}
.user-nav{
width: 75px;
height: 100%;
position: fixed;
background: #000;
z-index: 1000;
}
.container{
width: 100%;
height: 100%;
margin-left: 75px;
}
.viewport{
width: 70%;
background: #eee;
}
.header{
height: 50px;
background: #CCC;
position:fixed;
width: 70%;
}
.content{
padding-top: 50px;
}
.content p{
margin: 0px 0px 50px 0px;
}
.footer{
height: 50px;
position: fixed;
background: #CCC;
bottom: 0px;
width: 70%;
}
.right_panel{
position: fixed;
top: 0px;
right: 0px;
width: 30%;
height: 100%;
background: rgba(0,0,0,0.7);
color:#FFF;
}
HTML
<nav class="user-nav"></nav>
<div class="container">
<div class="viewport">
<div class="header">Header</div><!-- end .header -->
<div class="content">
LOTS OF CONTENT
</div><!-- end .content -->
<div class="footer">Footer</div><!-- end .footer -->
</div><!-- end .viewport -->
<div class="right_panel">fixed right panel</div><!-- end .right_panel -->
</div><!-- end .container -->
Again, any help on this would be greatly appreciated. Thanks.
.right_panelwidth:30% as you have already setmargin-left: 75px;on.container. So you should now set width of right_panel to70% - 75px + x = 100;. Have a look at jsfiddle.net/Dipak1991/709rcw8a/2%