<section class="grid">
<div class="box1"><img class="grid-img" src="https://picsum.photos/id/237/500/300" alt="pic1" width="500" height="300">
<p class="imgtext">
<button class="mybtn">Some text</button>
<span>Lorem ipsum</span>
</p>
</div>
<div class="box2"><img class="grid-img" src="https://picsum.photos/id/237/500/300" alt="pic1" width="500" height="300">
<p class="imgtext">
<button class="mybtn">Some text</button>
<span>Lorem ipsum</span>
</p>
</div>
<div class="box3"><img class="grid-img" src="https://picsum.photos/id/237/500/300" alt="pic1" width="500" height="300">
<p class="imgtext">
<button class="mybtn">Some text</button>
<span>Lorem ipsum</span>
</p>
</div>
<div class="box4"><img class="grid-img" src="https://picsum.photos/id/237/500/300" alt="pic1" width="500" height="300">
<p class="imgtext">
<button class="mybtn">Some text</button>
<span>Lorem ipsum</span>
</p>
</div>
<div class="box5"><img class="grid-img" src="https://picsum.photos/id/237/500/300" alt="pic1" width="500" height="300">
<p class="imgtext">
<button class="mybtn">Some text</button>
<span>Lorem ipsum</span>
</p>
</div>
</section>
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
Arial, sans-serif;
}
.grid {
display: grid;
max-width: 1280px;
margin: auto;
padding: 20px;
grid-template-areas:
"box1 box2 box2 box3"
"box1 box4 box5 box5";
grid-template-columns: 1.5fr 0.5fr 0.5fr 0.5fr;
grid-gap: 0.5rem;
margin-bottom: 1rem;
}
.grid > div {
position: relative;
}
.box1 {
grid-area: box1;
}
.box2 {
grid-area: box2;
}
.box3 {
grid-area: box3;
}
.box4 {
grid-area: box4;
}
.box5 {
grid-area: box5;
}
.grid-img {
width: 100%;
height: 100%;
object-fit: cover;
}
.imgtext {
position: absolute;
bottom: 1rem;
left: 0;
}
.mybtn {
-webkit-appearance: none;
appearance: none;
background: rgba(0, 255, 255, 0.7);
border: none;
border-radius: 0;
padding: 5px 10px;
color: white;
margin: 0 0 0.5rem;
font-size: 1rem;
}
.imgtext span {
display: block;
background: rgba(0, 0, 0, 0.5);
padding: 5px 10px;
color: white;
}
@media screen and (max-width: 800px) {
.grid {
display: block;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.