1

divの高さを取得する必要があります。コンテンツが変更される可能性があるため、CSSで高さを設定できません(内容によって異なります)。私は試した:

var buttonsHeight = $(".buttonsContainer").height();

var buttonsHeight = $(".buttonsContainer").outerHeight();

var buttonsHeight = $(".buttonsContainer").innerHeight();

いずれの場合buttonsHeightもですnull

CSS:

.buttonsContainer{
  padding:31px 16px 0;
  position:fixed;
}

フィドル: http://jsfiddle.net/U7Kck/3/

パディングを置き換える場合:20px 0; height:40px の場合、buttonsContainer は正常に見えます...

4

5 に答える 5

0

これを試して:

var elem = $('.buttonsContainer')[0];
buttonsHeight = window.getComputedStyle(elem, null).getPropertyValue('height');

のドキュメントはこちらからgetComputedStyle入手できます

于 2013-09-30T12:14:31.683 に答える
0
var buttonsHeight = $(".buttonsContainer")[0].clientHeight
于 2013-09-30T12:08:55.517 に答える