Skip to content

Instantly share code, notes, and snippets.

@JohannesMP
Created May 16, 2013 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesMP/5592550 to your computer and use it in GitHub Desktop.
Save JohannesMP/5592550 to your computer and use it in GitHub Desktop.
Template: aspect-ratio locked Divs floating to center with outline
/**
* Template: aspect-ratio locked Divs floating to center with outline
*/
.container {
text-align: center;
}
.image-wrapper {
display: inline-block;
width: 100%;
max-width: 600px;
background-size:100%;
background: url(http://i.imgur.com/VkUpwPi.png) no-repeat;
}
.image {
width:100%;
height:0;
padding-top:66.667%; /* 4x3 aspect ratio */
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);
}
<div class="container">
<div class="image-wrapper">
<div class="image">
<div class="image-overlay"></div>
</div>
</div>
<div class="image-wrapper">
<div class="image">
<div class="image-overlay"></div>
</div>
</div>
<div class="image-wrapper">
<div class="image">
<div class="image-overlay"></div>
</div>
</div>
</div>
// alert('Hello world!');
{"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