<ul class="products__list">
<li class="products__item product">
<figure class="product__figure">
<img class="poduct__img" src="https://picsum.photos/id/1002/300/300" alt="">
</figure>
<span class="product__new-label">new</span>
<h2 class="product__title">Title</h2>
<p class="product__price">12 000 ₽</p>
</li>
<li class="products__item product">
<figure class="product__figure">
<img class="poduct__img" src="https://picsum.photos/id/1003/300/300" alt="">
</figure>
<span class="product__new-label">new</span>
<h2 class="product__title">Title</h2>
<p class="product__price">12 000 ₽</p>
</li>
<li class="products__item product">
<figure class="product__figure">
<img class="poduct__img" src="https://picsum.photos/id/0/300/300" alt="">
</figure>
<span class="product__new-label">new</span>
<h2 class="product__title">Title</h2>
<p class="product__price">12 000 ₽</p>
</li>
<li class="products__item product">
<figure class="product__figure">
<img class="poduct__img" src="https://picsum.photos/id/123/300/300" alt="">
</figure>
<span class="product__new-label">new</span>
<h2 class="product__title">Title</h2>
<p class="product__price">12 000 ₽</p>
</li>
</ul>
<p>https://qna.habr.com/q/1164252</p>
@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600&display=swap");
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
font-family: "Nunito", sans-serif;
}
.products__list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 20px;
margin: 0;
padding-left: 0;
}
.product {
display: grid;
row-gap: 20px;
padding: 20px;
border-radius: 20px;
background: #7c9bba;
color: #fff;
}
.product__figure {
grid-column: 1/-1;
grid-row: 1/2;
display: grid;
margin: 0;
}
.product__figure::before {
/* для сохранения пропорций картинки */
content: "";
grid-column: 1/2;
grid-row: 1/2;
padding-top: 100%;
}
.poduct__img {
grid-column: 1/2;
grid-row: 1/2;
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 16px;
}
.product__new-label {
grid-column: 1/-1;
grid-row: 1/2;
padding-left: 20px;
padding-right: 20px;
}
.product__title {
grid-column: 1/-1;
grid-row: 1/2;
align-self: end;
justify-self: end;
padding-left: 20px;
padding-right: 20px;
font-weight: 600;
}
.product__price {
margin: 0;
font-size: 1.4em;
text-align: center;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.