Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created January 19, 2015 07:28
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 pbrocks/f5907764060c97ae9c77 to your computer and use it in GitHub Desktop.
Save pbrocks/f5907764060c97ae9c77 to your computer and use it in GitHub Desktop.
seamless image grid and img overlays
<div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="http://www.stockvault.net/data/2010/11/24/116234/small.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div><div class="bGImg">
<img src="https://farm4.staticflickr.com/3774/10670407354_bba85826ce_n.jpg" />
<p>THIS IS SOME OVERLAY TEXT</p>
</div>
* {
box-sizing: border-box;
font-family: arial, sans-serif;
}
body {
margin: 0;
padding: 0;
}
img {
width: 100%;
height: 100%;
vertical-align: bottom;
}
.bGImg {
background: #ddd;
width: 33.33%;
height: auto;
background-size: 100%;
position: relative;
overflow: hidden;
display: inline-table;
}
.bGImg p {
background: rgba(0, 0, 0, .4);
text-align: center;
position: absolute;
width: 100%;
height: 100%;
bottom: -100%;
left: 0;
padding: 1em;
margin: 0;
color: #fff;
opacity: 0;
-webkit-transition: opacity 500ms ease-out, bottom 1s ease-in-out;
-moz-transition: opacity 500ms ease-out, bottom 1s ease-in-out;
-o-transition: opacity 500ms ease-out, bottom 1s ease-in-out;
transition: opacity 500ms ease-out, bottom 1s ease-in-out;
}
.bGImg:hover p {
bottom: 0;
opacity: 1;
-webkit-transition: opacity 500ms ease-out, bottom 1s ease-in-out;
-moz-transition: opacity 500ms ease-out, bottom 1s ease-in-out;
-o-transition: opacity 500ms ease-out, bottom 1s ease-in-out;
transition: opacity 500ms ease-out, bottom 1s ease-in-out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment