Created
July 4, 2013 06:14
-
-
Save demsone/5925272 to your computer and use it in GitHub Desktop.
Centering Percentage Width/Height Elements
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
body { | |
background: #900; | |
} | |
.box { | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
transform: translate(-50%, -50%); | |
width: 70%; | |
height: 80%; | |
padding: 20px; | |
background: red; | |
color: white; | |
text-align: center; | |
box-shadow: 0 0 30px rgba(0, 0, 0, 0.2); | |
} | |
<div class="box"> | |
Percentage sized and still centered. | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment