Skip to content

Instantly share code, notes, and snippets.

@denzildoyle
Created June 6, 2014 01:30
Show Gist options
  • Save denzildoyle/1b0f27c5249bc21fb7f6 to your computer and use it in GitHub Desktop.
Save denzildoyle/1b0f27c5249bc21fb7f6 to your computer and use it in GitHub Desktop.
Vertical align anything with out the need to define its height. With only 5 lines of code.
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
@dwayne
Copy link

dwayne commented Jun 6, 2014

Looks good to me. Works in all modern browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment