【发布时间】:2017-01-21 06:28:04
【问题描述】:
我正在使用此功能垂直对齐以下link中有关项目的信息:
/* First make each project-section div full height */
$(window).on("load resize scroll", function(e) {
if ($(window).height() > 600 && $(window).width() > 980 ) {
screenHeight = $(window).height();
menuHeight = $('#main-header').outerHeight();
finalHeight = screenHeight - menuHeight;
$('.project-section').css('height', finalHeight + 'px');
/* Then Vertically align the elements */
var colHeightElement = $('.project-section > .et_pb_row > .et_pb_column');
colHeightElement.each(function( index ) {
var colHeight = $(this).outerHeight();
var colPadding = (finalHeight-colHeight)/2;
$(this).css('padding-top', colPadding + 'px');
});
}
});
正如您在链接中看到的,元素永远不会得到正确的高度,但我找不到原因。
【问题讨论】: