Last active
November 28, 2016 17:31
-
-
Save kiaratto/7141ea7155e2df9528080fc6bffcef75 to your computer and use it in GitHub Desktop.
Centraliza um elemento html dentro de outro elemento verticalmente. Funciona após o html montado já que utilizo o offsetHeight. Para centralizar horizontalmente utiliza-se o truque do margin:0 auto; na classe de estilo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CentralizaVerticalmente(elemento){ | |
elemento.style.marginTop = ((elemento.parentElement.offsetHeight / 2) - (elemento.offsetHeight / 2)) + "px"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment