Update/remove the media query and container class as needed.
<pre class="lang:js decode:true">var formHeightMQ = window.matchMedia("(min-width: 992px)");
var formWrapper = '.form';
var formHeights = {};

$('.gform_button').on('click', function(elem) {
    var $button = $(this);
    var formID = $button.attr('id').replace('gform_submit_button_', '');
    
    formHeights[formID] = $button.parents(formWrapper).height();
});

$(document).on('gform_confirmation_loaded', function(event, formId) {
    if (formHeightMQ.matches) {
        $('#gform_confirmation_wrapper_' + formId).parents(formWrapper).height(formHeights[formId.toString()]);
    }
});
</pre>