A Pen by Secret Sam on CodePen.
-
-
Save rolka/10787898 to your computer and use it in GitHub Desktop.
centering css
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
<div class="container"> | |
<div class="box"> | |
</div> | |
</div> |
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
.container { | |
height: 300px; | |
width: 300px; | |
background: #eee; | |
position: absolute; | |
margin: -150px 0 0 -150px; | |
left: 50%; | |
top: 50%; | |
} | |
.box { | |
height: 100px; | |
width: 100px; | |
background: #222; | |
position: absolute; | |
/*Centering Method 2*/ | |
margin: -50px 0 0 -50px; | |
left: 50%; | |
top: 50%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment