quagliato
8/6/2013 - 8:17 PM

Align a div vertically on the screen

Align a div vertically on the screen

var div_to_be_aligned = $('#middle');

var new_margin_top = 0;
var descontos = 0;

new_margin_top = (document.height - descontos - div_to_be_aligned.height()) / 2;
new_margin_top = new_margin_top + descontos / 2;

div_to_be_aligned.css('margin-top', new_margin_top + 'px');