I want to set up 2 div
s, one as a sidebar on the left and the other for displaying content on the page. Here's what I'm aiming for:
- Have the sidebar div height at 100%
- Set the body height to 100% as well
- Make sure the body's width adjusts when the sidebar width changes
This is the code snippet I have been experimenting with:
#Sidebar{
background-color:#F0F0F0;
height: calc(100% - 80px);
width: 257px;
position: fixed;
left: 0;
bottom: 0;
overflow:hidden;
white-space: nowrap;
}
#content {
margin: 0;
position: fixed;
height: 100%;
}
However, the content in the div
ends up showing inside the Sidebar instead!
#Sidebar {
height: calc(100% - 80px);
width: 257px;
position:fixed;
top:0;
left: 0;
bottom: 0;
overflow:hidden;
white-space:nowrap;
border:1px solid #000;
}
#content {
margin: 0;
position:fixed;
height: 100%;
border:1px solid tomato;
}
<div id="Sidebar">
Hello World!!
</div>
<div id="content">
Content Div
</div>
Note that I am using jQuery .Resizable to adjust the width dynamically. You can also check out the working example on jsfiddle here.