JSFiddle - React, Tailwind, and code Playground
HTML
<div class="items">
<div class="group_of_4">
<div class="item__heading">
Item 1
</div>
<div class="item__content">
Some content that is not that long
</div>
<div class="item__features">
<ul>
<li>feature 1</li>
</ul>
</div>
<div class="item__price">
£99.99
</div>
<div class="item__heading">
Item 2
</div>
<div class="item__content">
Some content that is longer than other items on the same row and sets the height of this section as it spans many more lines than the rest of the other content sections on this row
</div>
<div class="item__features">
<ul>
<li>feature 1</li>
</ul>
</div>
<div class="item__price">
£69.99
</div>
<div class="item__heading">
Item 3
</div>
<div class="item__content">
Some content that is not that long
</div>
<div class="item__features">
<ul>
<li>feature 1</li>
<li>feature 2</li>
<li>feature 3</li>
</ul>
</div>
<div class="item__price">
£69.99
</div>
<div class="item__heading">
Item 4
</div>
<div class="item__content">
Some content that is not that long
</div>
<div class="item__features">
<ul>
<li>feature 1</li>
</ul>
</div>
<div class="item__price">
£109.99
</div>
</div>
<div class="group_of_4">
<div class="item__heading">
Item 5
</div>
<div class="item__content">
Some content that is a medium kind of length blah blah
</div>
<div class="item__features">
<ul>
<li>feature 1</li>
</ul>
</div>
<div class="item__price">
£29.99
</div>
<div class="item__heading last2">
Item 6
</div>
<div class="item__content last2">
Some content that is not that long
</div>
<div class="item__features last2">
<ul>
<li>feature 1</li>
</ul>
...
CSS
.items {
display: flex;
flex-direction: column;
max-width: 1200px;
}
.items .group_of_4 {
display: flex;
flex-wrap: wrap;
}
.items .group_of_4 ~ .group_of_4 {
margin-top: 24px;
}
.items .group_of_4 > div {
width: 25%;
box-sizing: border-box;
padding: 12px;
}
.item__heading {
background-color: #d4d0f5;
padding: 10px;
text-align: center;
border: 1px solid #bbbbbb;
order: 1;
}
.item__content {
padding: 10px;
border-left: 1px solid #bbbbbb;
border-right: 1px solid #bbbbbb;
order: 2;
}
.item__features {
padding: 10px;
border-left: 1px solid #bbbbbb;
border-right: 1px solid #bbbbbb;
background-color: #f7cbb1;
order: 3;
}
.item__price {
background-color: #e0f6d9;
padding: 10px;
text-align: center;
border: 1px solid #bbbbbb;
order: 4;
}
/* one item in a group */
.items .group_of_4 .last1 {
margin-right: 75%;
}
/* two items in a group */
.items .group_of_4 .last2 {
margin-right: 50%;
}
/* three items in a group */
.items .group_of_4 .last3 {
margin-right: 25%;
}
@media (max-width: 600px) {
.items .group_of_4 > div:nth-child(8) ~ .item__heading {
margin-top: 24px;
order: 5;
}
.items .group_of_4 > div:nth-child(8) ~ .item__content {
order: 6;
}
.items .group_of_4 > div:nth-child(8) ~ .item__features {
order: 7;
}
.items .group_of_4 > div:nth-child(8) ~ .item__price {
order: 8;
}
.items .group_of_4 > div {
width: 50%;
}
/* one item in a group */
/* three items in a group */
.items .group_of_4 .last1,
.items .group_of_4 .last3 {
margin-right: 50%;
}
/* two items in a group */
.items .group_of_4 .last2 {
margin-right: 0%;
}
}