If all you want is a responsive layout with text over the images you could simply add the text in an absolutely positioned div inside the element. Notice how the div text is inside their respective elements and on top of the images.
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0;
}
html {
font-family: sans-serif;
}
body {
display: flex;
align-items: center;
}
.wrapper {
overflow: hidden;
margin: auto;
background-color: #c06;
}
div > div {
width: 9rem;
margin: 0 0.125rem;
background-color: #c06;
float:left;
position: relative;
}
div:nth-child( 4n ){
clear: left;
}
.note {
width: 100%;
padding: 1rem;
background-color: #000;
color: #eee;
text-align: center;
position: absolute;
z-index: 10;
top: 0;
left: 0;
}
img {
max-width: 100%;
}
div div:nth-child( 1 ) img{
filter: grayscale( 100% );
}
div div:nth-child( 3 ) img{
filter: brightness( 150% );
}
div div:nth-child( 4 ) img{
filter: hue-rotate( 205deg );
}
div div:nth-child( 5 ) img{
filter: saturate( 250% );
}
div div:nth-child( 6 ) img{
filter: invert( 100% );
}
.txt {
background-color: transparent;
color: #eee;
position: absolute;
top: 50%;
transform: translateY( -50% );
text-align: center;
font-size: 2rem;
text-shadow: 0 0 0.5rem #000;
}
@media( max-width: 1025px ){
div:nth-child( 2n + 3 ){
clear: left;
}
div:nth-child( 4n ){
clear: none;
}
.note {
background-color: rgba( 0, 0, 0, 0.8 );
}
}
<div class="note">Resize viewport to change layout</div>
<div class="wrapper">
<div>
<img src="http://i.imgur.com/iyzGnF9.jpg">
<div class="txt">div text 1</div>
</div>
<div>
<img src="http://i.imgur.com/iyzGnF9.jpg">
<div class="txt">div text 2</div>
</div>
<div>
<img src="http://i.imgur.com/iyzGnF9.jpg">
<div class="txt">div text 3</div>
</div>
<div>
<img src="http://i.imgur.com/iyzGnF9.jpg">
<div class="txt">div text 4</div>
</div>
<div>
<img src="http://i.imgur.com/iyzGnF9.jpg">
<div class="txt">div text 5</div>
</div>
<div>
<img src="http://i.imgur.com/iyzGnF9.jpg">
<div class="txt">div text 6</div>
</div>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…