Created
May 16, 2013 18:09
-
-
Save JohannesMP/5593763 to your computer and use it in GitHub Desktop.
Template: aspect-ratio locked Divs floating to center with outline
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
/** | |
* Template: aspect-ratio locked Divs floating to center with outline | |
*/ | |
body { | |
margin: 80px; | |
padding: 0; | |
} | |
.image-grid { | |
text-align: center; | |
font-size: 0; /* removes default horizontal spacing on inline-block */ | |
} | |
.image-grid > * { | |
vertical-align: top; /* removes default vertical spacing on inline-block */ | |
display: inline-block; | |
} | |
.image-wrapper { | |
width: 100%; | |
max-width: 400px; | |
} | |
.image-content { | |
width:100%; | |
height:0; | |
padding-top:66.666%; /* 3x2 aspect ratio */ | |
background-image: url(http://i.imgur.com/VkUpwPi.png); | |
background-repeat: no-repeat; | |
background-position: center; | |
background-size: 100% auto; | |
position: relative; /* necessary to keep the position: absolute contained*/ | |
} | |
.image-overlay { | |
position: absolute; | |
top: 0; right: 0; bottom: 0; left: 0; | |
/*background: url(http://i.imgur.com/HeYHtzI.png);*/ | |
background-repeat: no-repeat; | |
background-size: 100% 100%; | |
border: 5px solid rgba(0,0,0,0.5); | |
} |
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="image-grid"> | |
<div class="image-wrapper"> | |
<div class="image-content"> | |
<div class="image-overlay"></div> | |
</div> | |
</div> | |
<div class="image-wrapper"> | |
<div class="image-content"> | |
<div class="image-overlay"></div> | |
</div> | |
</div> | |
<div class="image-wrapper"> | |
<div class="image-content"> | |
<div class="image-overlay"></div> | |
</div> | |
</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
// alert('Hello world!'); |
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
{"view":"separate","fontsize":"80","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment