Placing a scrollable div below a fixed div of variable height

后端 未结 2 1214
旧时难觅i
旧时难觅i 2021-01-15 17:30

This is with respect to a mobile page in jquery mobile

I have 2 divs as follows within a parent div(data-role=header)

相关标签:
2条回答
  • 2021-01-15 18:12

    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.

    0 讨论(0)
  • 2021-01-15 18:24

    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

    0 讨论(0)
提交回复
热议问题