<div class="card card--hero">
<img src="https://picsum.photos/2568/600?random=21" width="2568" height="600" alt="" class="card__thumbnail" />
<div class="card__badge">Must Try</div>
<h3 class="card__title">Best Brownies in Town</h3>
<p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
<button class="card__button">Order now</button>
</div>
<div class="container">
<div class="card">
<img src="https://picsum.photos/2568/600?random=1" width="2568" height="600" alt="" class="card__thumbnail" />
<div class="card__badge">Must Try</div>
<h3 class="card__title">Best Brownies in Town</h3>
<p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
<button class="card__button">Order now</button>
</div>
<div class="card">
<img src="https://picsum.photos/2568/600?random=2" width="2568" height="600" alt="" class="card__thumbnail" />
<div class="card__badge">Must Try</div>
<h3 class="card__title">Best Brownies in Town</h3>
<p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
<button class="card__button">Order now</button>
</div>
<div class="card">
<img src="https://picsum.photos/2568/600?random=3" width="2568" height="600" alt="" class="card__thumbnail" />
<div class="card__badge">Must Try</div>
<h3 class="card__title">Best Brownies in Town</h3>
<p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
<button class="card__button">Order now</button>
</div>
<div class="card">
<img src="https://picsum.photos/2568/600?random=4" width="2568" height="600" alt="" class="card__thumbnail" />
<div class="card__badge">Must Try</div>
<h3 class="card__title">Best Brownies in Town</h3>
<p class="card__describe">High quality ingredients and best in-class chef. Light, tender, and easy to make~</p>
<button class="card__button">Order now</button>
</div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
font-family: "Exo", Arial, sans-serif;
background-color: #557;
display: grid;
gap: 20px;
align-items: start;
}
img {
display: block;
max-width: 100%;
height: auto;
}
.card {
display: grid;
border-radius: 10px;
background-color: #fff;
color: #454545;
box-shadow: 0 0 0.35em 0 rgb(0 0 0 / 0.5);
grid-template-columns: 160px auto;
grid-template-rows: min-content min-content auto;
grid-template-areas:
"thumbnail title"
"thumbnail describe"
"thumbnail button";
gap: 10px 0;
}
.card__thumbnail {
object-fit: cover;
object-position: center;
grid-area: thumbnail;
aspect-ratio: 1 / 1.25;
border-radius: 10px 0 0 10px;
z-index: 1;
}
.card__badge {
background-color: #2196f3;
border-radius: 0 10rem 10rem 0;
align-self: start;
justify-self: start;
margin-top: 2rem;
color: #fff;
padding: 5px 12px 5px 8px;
text-shadow: 0 0 1px rgb(0 0 0 / 0.5);
filter: drop-shadow(0px 0px 2px rgb(0 0 0 / 0.5));
grid-area: thumbnail;
z-index: 2;
display: flex;
}
.card__title {
font-weight: 700;
font-size: clamp(1.2rem, 1.2rem + 3vw, 1.5rem);
padding: 0 20px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
grid-area: title;
margin-top: 20px;
align-self: start;
}
.card__describe {
color: #666;
line-height: 1.4;
padding: 0 20px;
display: box;
box-orient: vertical;
line-clamp: 2;
overflow: hidden;
grid-area: describe;
align-self: start;
}
.card__button {
display: inline-flex;
justify-content: center;
align-items: center;
border: none;
border-radius: 10rem;
background-color: #feca53;
padding: 10px 20px;
color: #000;
text-decoration: none;
box-shadow: 0 3px 8px rgb(0 0 0 / 7%);
transition: all 0.2s linear;
font-weight: 700;
justify-self: end;
margin: 0 20px 20px 0;
cursor: pointer;
grid-area: button;
align-self: end;
}
.card__button:hover {
background-color: #ff9800;
}
.card--hero {
grid-template-areas:
"title title title"
"describe describe describe"
"button button button";
grid-template-rows: none;
grid-template-columns: none;
grid-auto-rows: auto;
align-items: center;
justify-content: center;
align-content: center;
border-radius: 0;
}
.card--hero::after,
.card--hero::before {
content: "";
display: block;
grid-area: 1 / 1 / 4 / 4;
z-index: 2;
background-image: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 100vw 100vw;
background-color: rgb(0 0 0 / 0.5);
opacity: 0.5;
width: 100%;
height: 100%;
border-radius: 0;
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
backdrop-filter: blur(4px);
}
.card--hero::before {
z-index: 3;
}
.card--hero > * {
z-index: 4;
justify-self: center;
}
.card--hero .card__thumbnail {
grid-area: 1 / 1 / 4 / 4;
aspect-ratio: 2 / 1;
border-radius: 0;
z-index: 1;
}
.card--hero .card__badge {
display: none;
}
.card--hero .card__title {
grid-area: title;
align-self: end;
margin-top: 0;
color: #fff;
font-size: clamp(1rem, 1rem + 4vw, 2rem);
}
.card--hero .card__describe {
grid-area: describe;
margin-top: 0;
color: #fff;
text-align: center;
font-size: 1rem;
}
.card--hero .card__button {
--purple: #7f00ff;
--pink: #e100ff;
grid-area: button;
margin: 0;
align-self: start;
padding: 1em 2em;
font-size: 1rem;
text-shadow: 1px 1px 1px rgb(0 0 0 / 50%);
text-transform: uppercase;
background: linear-gradient(to right, var(--purple), var(--pink));
position: relative;
color: #fff;
margin-top: -2rem;
}
.card--hero .card__button::after {
content: "";
position: absolute;
z-index: -1;
inset: 0;
opacity: 0.8;
border-radius: 10rem;
background: inherit;
filter: blur(30px);
transition: all 0.2s;
}
.card--hero .card__button:hover::after {
filter: blur(32px);
bottom: -5px;
}
.card--hero .card__button:hover:active::after {
filter: blur(10px);
bottom: -6px;
}
.container {
padding-left: 20px;
padding-right: 20px;
display: grid;
gap: 20px;
width: 100%;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
@media (min-width: 700px) {
.card {
grid-template-columns: none;
grid-template-areas:
"thumbnail"
"title"
"describe"
"button";
grid-template-rows: none;
gap: 20px;
}
.card__badge {
grid-area: thumbnail;
}
.card__thumbnail {
aspect-ratio: 16 / 9;
border-radius: 10px 10px 0 0;
}
.card__title {
margin-top: 0;
}
.card__describe {
margin-top: 0;
}
.card.card--hero {
grid-template-areas:
"title title title"
"describe describe describe"
"button button button";
}
.card--hero .card__thumbnail {
aspect-ratio: 16 / 9;
max-height: 300px;
}
}
@media (min-width: 1024px) {
.container {
max-width: 80vw;
margin: 0 auto;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.