2013-11-02 158 views
0

我想用窗口的高度來創建div,但高度可以自動升級嗎?自動調整div的高度

$(document).ready(function() { 

    var hpd = $(document).height(); 
    var hph = $(".header").height(); 

    $('.wrapper').css({height: hpd }) 
    $('.contenido').css({height: hpd-hph-1 }) 

}); 
+1

您可以在CSS中做到這一點:'高度:100%'。只要確保所有的父元素都有這個集合。另外,你的意思是「自動升級」? –

回答

2

試試這個

$(document).ready(function(){ 
    $(window).resize(function(){ 
      $(".example").height ($(this).height()); 
    }); 
});