JQuery的页面高度错误
我将一个页面分为五个JQuery的页面高度错误,jquery,css,Jquery,Css,我将一个页面分为五个div,每个人都使用FLOAT:LEFT将它们放在同一页面的五列中。 我给出了一个高度:100%,到目前为止一切都很完美。但是,如果我在页面上放置了比上面高度更长的内容,我使用了以下代码: var i; // there five divs with id div1, div2, div3, div4, div5 for (i=1; i<=5; i++) $( "#div" + i ).height($( document ).height()); v
div
,每个人都使用FLOAT:LEFT
将它们放在同一页面的五列中。
我给出了一个高度:100%
,到目前为止一切都很完美。但是,如果我在页面上放置了比上面高度更长的内容,我使用了以下代码:
var i;
// there five divs with id div1, div2, div3, div4, div5
for (i=1; i<=5; i++)
$( "#div" + i ).height($( document ).height());
vari;
//有五个div,id为div1、div2、div3、div4、div5
对于(i=1;i可能需要执行窗口视口高度:
$( "#div" + i ).height($( window ).height());
如果以百分比形式使用高度,如将div height设置为100%,请确保:
html,body{height: 100%;}
使用
$(document).outerHeight()
而不是
$(document).height()
我不能100%确定您的要求,但为什么不使用CSS来实现这一点呢
你试过使用高度:100vh吗
这里是对视口高度/宽度的引用
请发布您的标记和CSS,并考虑组合一个JSFIDLE。