Skip to content

Instantly share code, notes, and snippets.

@quagliato
Created August 6, 2013 20:17
Show Gist options
  • Save quagliato/6168210 to your computer and use it in GitHub Desktop.
Save quagliato/6168210 to your computer and use it in GitHub Desktop.
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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment