Skip to content

Instantly share code, notes, and snippets.

@rafszul
Created February 16, 2017 01:48
Show Gist options
  • Select an option

  • Save rafszul/d0eb346073505f24b8e6c02cacc4c994 to your computer and use it in GitHub Desktop.

Select an option

Save rafszul/d0eb346073505f24b8e6c02cacc4c994 to your computer and use it in GitHub Desktop.
Vertically and horizontally aligned
<div class="table-cell">
<h1 class="element">Table Cell</h1>
</div>
<div class="flex">
<h1>Flex</h1>
</div>
.table-cell {
width: 100%;
display: table;
height: 100%;
margin: 0 auto;
.element {
display: table-cell;
vertical-align: middle;
text-align: center;
}
}
.flex {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
// Demo Content
html,
body {
height: 100%;
}
div {
&:nth-child(1) {
background: yellow;
}
&:nth-child(2) {
background: salmon;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment