我有以下代码获取正文height并将其写入显示为 a 的 div,table-cell因此内容可以垂直居中于resize. 我已经对此进行了测试,并且效果很好。
$( window).resize(function() {
bodyHeight = $('body').outerHeight();
console.log('bodyHeight =' + bodyHeight);
$('.table-cell').css('height', bodyHeight +'px');
});
现在,如果我尝试使用下面的代码将其放入 Drupal。它不起作用。之所以调用 jQuery,是因为我可以在 Drupal 中运行脚本,但在我指定在resize.
jQuery(window).resize(function($) {
bodyHeight = $('body').outerHeight();
console.log('bodyHeight =' + bodyHeight);
$('.table-cell').css('height', bodyHeight +'px');
});