This is with respect to a mobile page in jquery mobile
I have 2 divs as follows within a parent div(data-role=header)
CSS:
.inner-topHeader-panel {
width: 100%;
height: auto;
margin: 20;
background: white;
border-bottom: none;
float: left;
clear: both;
top: 0;
z-index: 1000;
}
.inner-centercontent {
width: 100%;
float: left;
height: 600px;
overflow: scroll;
padding-bottom: 50px;
}
Plunker
Will only scroll when height is smaller than inner content.
On pageshow
, calculate the height of the fixed div and set the margin-top
of the div below it to that value:
$(document).on("pageshow", "#page1", function(){
var fixedH = $(".inner-topHeader-panel").outerHeight(true);
$(".inner-centercontent").css("margin-top", fixedH + "px");
});
DEMO