jQuery和CSS最小高度:100%

时间:2021-03-09 20:26:40

MY CSS:

body{
    width:100%;
    min-height:100%;
}

MY JQ:

function abc(){
   var h_1 = jQuery('.top_menu_container').height();
   var h_2 = jQuery('.bottom_container').height();
   var sum = h_1 + h_2;
   var body_h = jQuery('body').height();

   jQuery('.s1_container').css('height',( body_h - sum ) + 'px');
}

setInterval(abc,1000);

And what is goind on... When "body" have min-height:100%; and I change widow width to for example less than 767px when body have overflow-y:visible , body height is bigger and bigger for every setInterval - it summed earlier height + current height. I need min-height for body because it has background

什么是goind ...当“身体”有最小高度:100%;并且当我的身体有溢出时,我将寡妇宽度改为例如小于767px:可见,每个setInterval的身高越来越大 - 它总结了之前的身高+当前身高。我需要身高的最小高度,因为它有背景

1 个解决方案

#1


0  

What if just use vh? )

如果只使用vh怎么办? )

body {
    min-height:100vh;
}

#1


0  

What if just use vh? )

如果只使用vh怎么办? )

body {
    min-height:100vh;
}