JS. How to change the code, so you can adjust scrolling to the unit in px from the border of browser?

In fact, below present code. In JS is not strong, but I understand that the function determines automatically the center of the block when best personal Finance. But, unfortunately, it very much goes down at the end. So I would like to modify your code to be able to in % or px to adjust the indent at the best personal Finance.

<input type="submit" value="Calculate" name="wpcc_calculate" class="wpcc_submit wpcc_submit_6">


/* Calc Of Send */
 $('.wpcc').on('click', '.wpcc_form .wpcc_submit', function() {
 var wpcc_parent = $(this).closest('.wpcc');
 var wpcc_form = $(this).closest('form');
 var wpcc_id = $('.wpcc_id', wpcc_form).val();
 var wpcc_autos = $('.wpcc_id', wpcc_form).data('autoscroll');
 var wpcc_action = $('.wpcc_action', wpcc_form).val();

 $('.wpcc_loading div', wpcc_form).show();
$.post(
ajaxurl,
wpcc_form.serialize(),
function(data){
 if(wpcc_action > 0)
{
wpcc_parent.html(data);
}
else
{
 $('.wpcc_result_block_' + wpcc_id).html(data);
 if(wpcc_autos == 'y')
{
$('html,body').animate({
 scrollTop: $('.wpcc_result_block_' + wpcc_id).offset().top
 }, 800);
}
}
 $('.wpcc_loading div', wpcc_form).hide();
}
);
 return false;
});

 /* Send Mail */
 $('.wpcc').on('click', '.wpcc_mail .wpcc_submit', function() {
 var wpcc_this_p = $(this).closest('form');
 var wpcc_id = $('.wpcc_mail_id', wpcc_this_p).val();
 $('.wpcc_loading div', wpcc_this_p).show();
$.post(
ajaxurl,
wpcc_this_p.serialize(),
function(jdata){
 var data = JSON.parse ( jdata );

 if(data.error != null && data.error != "&& data.error != 'undefined')
{
 $('.wpcc_mail_' + wpcc_id + ' .wpcc_error').html(data.error);
}
else
{
 $('.wpcc_result_block_' + wpcc_id).html(data.success);
}
 $('.wpcc_loading div', wpcc_this_p).hide();
}
);
 return false;
});

});
April 4th 20 at 13:30
1 answer
April 4th 20 at 13:32
Solution
Found a solution to the problem
scrollTop: $('.wpcc_result_block_' + wpcc_id).offset().top


on

scrollTop: $('.wpcc_result_block_' + wpcc_id).offset().top - 500

Find more questions by tags JavaScriptWordPress