Last active
July 9, 2016 09:39
-
-
Save alexcican/7000200 to your computer and use it in GitHub Desktop.
Centring a div vertically and horizontally with CSS Flexbox (tested on Chrome 30, Safari 6, Firefox 24, Mobile Safari iOS 7, Mobile IE 10)
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
.parent { | |
display: flex; | |
height: 500px; | |
} | |
.child { | |
max-width: 20em; | |
margin: auto; | |
border: solid 1px; | |
} | |
/* alternative */ | |
.flexcontainer { | |
display: -webkit-flex; | |
display: -ms-flexbox; | |
display: flex; | |
-webkit-flex-direction: row; | |
-ms-flex-direction: row; | |
flex-direction: row; | |
-webkit-align-items: center; | |
-ms-flex-align: center; | |
align-items: center; | |
-webkit-justify-content: center; | |
-ms-flex-pack: center; | |
justify-content: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment