set div height using jquery (stretch div height)

前端 未结 6 1957
抹茶落季
抹茶落季 2020-12-04 17:37

I have 3 divs with ids header, content and footer. Header and footer has fixed height and they are styled to float on top and bottom.

6条回答
  •  清歌不尽
    2020-12-04 18:24

    $(document).ready(function(){ contsize();});
    $(window).bind("resize",function(){contsize();});
    
    function contsize()
    {
    var h = window.innerHeight;
    var calculatecontsize = h - 70;/*if header and footer heights= 35 then total 70px*/ 
    $('#content').css({"height":calculatecontsize + "px"} );
    }
    

提交回复
热议问题