I have three divs which are stacked with css on top of each other. The middle one should be a draggable separator, such that the top div and its content is above and the other div is below. And each has its own scrollbar. See jsfiddle
It works however if find my js code not very nice because it set the heights of the three divs separately:
The html:
<div id="wrapper">
<div id="content">
<div id="dragger"></div>
<div id="footer"></div>
</div>
The css code
#wrapper {
height: 100%;
width: 100%;
overflow: auto;
position: relative;
}
#content {
position: fixed;
bottom: 25%;
width:100%;
height: 75%;
overflow:scroll;
overflow-x:hidden;
}
#dragger {
position: fixed;
bottom: 25%;
width:100%;
cursor: ns-resize;
height: 5px;
}
#footer {
position: fixed;
bottom: 0;
width:100%;
height: 25%;
overflow:scroll;
overflow-x:hidden;
}
The js code:
...
$('#footer').css({
"height": bodySize - e.pageY
});
$('#content').css({
"bottom": bodySize - e.pageY,
"height": e.pageY
});
$('#dragger').css({
"bottom": bodySize - e.pageY
});
...
Is there a better way to achieve the same behavior, I thought of some way to make the footer and content div height depending on the position of dragger in css. But I do not know how. Can anyone help me?