JQuery .height()没有按预期工作

Dev*_*per 1 html css jquery

我正在制作一个日历网站.在这里我有一个日历div,其中日历加载,包含在内容div中.在这个页眉和页脚是固定的位置.日历加载蓝色部分.

在此输入图像描述

HTML

<div class ="content">
   <div id="calendar"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

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;

}
Run Code Online (Sandbox Code Playgroud)

JS

var calHeight = $(".content").height();
Run Code Online (Sandbox Code Playgroud)

从图像我认为calHeight应该给390左右的东西,但它在chrome中给出594和在firefox中给出565..

我该怎么做才能让calHeight显示大小?

小智 6

尝试使用jQuery.outerHeight().

http://api.jquery.com/outerHeight/

它返回包括Margin和Padding在内的高度.