基于窗口高度和第二分区高度的Javascript动态分区高度
如何修改下面的代码,使is不减210而减另一个div height,从而使方程式实质上变为“主菜单=窗口高度-div height” 这是你的电话号码 这样的标记:基于窗口高度和第二分区高度的Javascript动态分区高度,javascript,jquery,dynamic,html,Javascript,Jquery,Dynamic,Html,如何修改下面的代码,使is不减210而减另一个div height,从而使方程式实质上变为“主菜单=窗口高度-div height” 这是你的电话号码 这样的标记: <div id="main-menu"></div> <div id="other-div"> <h1>Sample Content</h1> <p> foo bar foo bar foo bar foo bar foo ba
<div id="main-menu"></div>
<div id="other-div">
<h1>Sample Content</h1>
<p>
foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
</p>
</div>
#other-div {
background: #cdcdcd;
}
$('#main-menu').height($(window).height()-$("#other-div").height());
Javascript如下所示:
<div id="main-menu"></div>
<div id="other-div">
<h1>Sample Content</h1>
<p>
foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
</p>
</div>
#other-div {
background: #cdcdcd;
}
$('#main-menu').height($(window).height()-$("#other-div").height());
从脚本中可以看到,我调用了height函数。不,div的高度不是固定的,它是基于内容的,不是吗。