Last active
September 16, 2016 16:35
-
-
Save aligator28/c75013e3538290172f18c78a8ce08ff0 to your computer and use it in GitHub Desktop.
div centered horizontally and vertically
This file contains hidden or 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
//first example (works good) | |
background: red | |
position: absolute | |
color: #fff | |
top: 50% | |
left: 50% | |
padding: 15px | |
-ms-transform: translateX(-50%) translateY(-50%) | |
-webkit-transform: translate(-50%,-50%) | |
transform: translate(-50%,-50%) | |
//second flexbox | |
display: flex | |
align-items: center | |
//third with table (someone said the safest method) | |
.top | |
display: table | |
height: 100% | |
margin: 0 auto | |
position: relative | |
z-index: 10 | |
color: red | |
.tbl-cell | |
display: table-cell | |
vertical-align: middle | |
justify-content: center | |
height: 100% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment