Trying to achieve the repeating patterns like the one in the image below using css grid:
Tried using the CSS grid , see the code pen
.parent {
display: grid;
grid-gap: 20px;
direction: rtl;
padding-bottom: 20px;
}
.item--img-cont img {
width: 100%;
}
.item--text-cont {
color: white;
}
.item {
background: black;
}
/*START:Desktop Style */
@media screen and (min-width:1280px) {
.parent {
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
}
.item:nth-child(10n+1) {
grid-column-start: 1;
grid-column-end: 3;
grid-row-start: 1;
grid-row-end: 3;
}
.item:nth-child(10n+10) {
grid-column-start: 3;
grid-column-end: 5;
grid-row-start: 3;
grid-row-end: 5;
}
}
/*END:Desktop Style */
<!--START: Set 1-->
<div class="parent">
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-1" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-2" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-3" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-4" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-5" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-1" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-2" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-3" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-4" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-5" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-1" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-2" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-3" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-4" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-5" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-1" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-2" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-3" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-4" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
<!--START: Item-->
<div class="item">
<div class="item--img-cont">
<img src="http://via.placeholder.com/1600x900?text=Box-5" alt="placeholder-image" />
</div>
<div class="item--text-cont">
This is dummy text . It is variable
</div>
</div>
<!--END: Item-->
</div>
<!--END: Set 1-->
I am not able to achieve the pattern than the first one.
It is working only when I give the hardcoded value for grid-row-start property.
Note: Don't change the DOM structure. Thanks in advance for any help.
