How to get a scrollbar in a div with fixed header and footer?

后端 未结 4 1865
挽巷
挽巷 2020-12-16 18:10

I have an website and some problems with the scrollbar.

What I want I can best explain with this image.

<script

4条回答
  •  长情又很酷
    2020-12-16 18:30

    See my fiddle for entire logic fiddle http://jsfiddle.net/MA9k3/7

    Jquery code:

    var doc_height = $(window).innerHeight();
    
    var header_height = $("header").height();
    var footer_height = $("footer").height();
    
    var div_height = doc_height - (header_height + footer_height);
    
    $("#content").css({
        "height": (div_height - footer_height) + "px",
        "margin-bottom": footer_height + "px"
    });
    
    alert($("#content").height());
    

提交回复
热议问题