我正在做一个日历网站。在这里我有一个日历div,其中的日历加载,包装在一个内容div。在这个页眉和页脚是固定的位置。日历在蓝色部分加载。
HTML格式
<div class ="content">
<div id="calendar"></div>
</div>
CSS
.content{
background: #fcfcfc;
height: 100%;
margin: -70px 0 -20px;
padding: 70px 0 20px;
}
#calendar{
background: #fcfcfc;
margin: 10px 10px 10px 10px;
border: 1px solid #888;
}
JS公司
var calHeight = $(".content").height();
从图片上看,我认为calHeight应该提供大约390个,但它在chrome中提供594个,在firefox中提供565个。。
我该怎么做才能使calHeight达到显示的大小?
最佳答案
尝试使用jQuery.outerHeight()。
http://api.jquery.com/outerHeight/
它返回包括边距和填充在内的高度。