A Pen by Piotr Łepkowski on CodePen.
Created
June 15, 2016 18:26
-
-
Save ozrabal/a32e49deac35c22f487675f87fe4010c to your computer and use it in GitHub Desktop.
NrrRQy
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
<div class="centered"> | |
<div class="logo"> | |
<img src="http://placehold.it/350x350"> | |
</div> | |
<div class="caption"> | |
<p>Percentage sized and still centered.</p> | |
</div> | |
</div> |
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; | |
} | |
.logo { | |
height: 100%; | |
position: relative; | |
} | |
img { | |
//height: 100%; | |
max-width: 100%; | |
max-height: 100%; | |
position: relative; | |
} | |
.caption{ | |
display: block; | |
position: relative; | |
padding:0; | |
background: #ccc; | |
margin-top: 25px; | |
} | |
p{ | |
margin: 0; | |
padding: 10px; | |
} | |
.centered { | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
transform: translate(-50%, -50%); | |
/* | |
This doesn't work | |
margin-left: -25%; | |
margin-top: -25%; | |
*/ | |
width: 40%; | |
height: 50%; | |
padding: 20px; | |
background: red; | |
color: white; | |
text-align: center; | |
box-shadow: 0 0 30px rgba(0, 0, 0, 0.2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment