Skip to content

Instantly share code, notes, and snippets.

@peteroid
Created August 3, 2016 17:20
Show Gist options
  • Save peteroid/d28f994e6da15d3e2f96d43c79ed4666 to your computer and use it in GitHub Desktop.
Save peteroid/d28f994e6da15d3e2f96d43c79ed4666 to your computer and use it in GitHub Desktop.
An example implementing the vertical alignment
/* absolution position + transform approach */
.parent {
height: 100vh;
position: relative;
.children {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
/* display table approach, working for min height on parent */
.parent {
display: table;
min-height: 100vh;
.children {
display: table-cell;
vertical-align: middle;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment