<p class="notification">See also <a href="https://codepen.io/tutsplus/full/xxWOjPX" target="_blank">Responsive Image Grid With CSS Grid (Advanced Example)</a></p>
<h1>Meet Morocco Through Beautiful <a href="https://unsplash.com/" target="_blank">Unsplash</a> Photos</h1>
<ul class="grid">
<li>
<figure>
<img width="640" height="1138" src="https://assets.codepen.io/162656/morocco4.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="427" src="https://assets.codepen.io/162656/morocco1.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="427" src="https://assets.codepen.io/162656/morocco3.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="427" src="https://assets.codepen.io/162656/morocco6.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="418" src="https://assets.codepen.io/162656/morocco5.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="853" src="https://assets.codepen.io/162656/morocco2.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="314" src="https://assets.codepen.io/162656/morocco7.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="427" src="https://assets.codepen.io/162656/morocco8.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="960" src="https://assets.codepen.io/162656/morocco9.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="427" src="https://assets.codepen.io/162656/morocco11.jpg" alt="">
</figure>
</li>
<li>
<figure>
<img width="640" height="427" src="https://assets.codepen.io/162656/morocco10.jpg" alt="">
</figure>
</li>
</ul>
<footer class="page-footer">
<span>made by </span>
<a href="https://georgemartsoukos.com/" target="_blank">
<img width="24" height="24" src="https://assets.codepen.io/162656/george-martsoukos-small-logo.svg" alt="George Martsoukos logo">
</a>
</footer>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
margin: 80px 0 24px;
font-family: sans-serif;
}
a {
color: inherit;
}
.notification {
position: fixed;
top: 0;
left: 0;
right: 0;
padding: 10px;
text-align: center;
z-index: 1;
background: #fffbbc;
}
h1 {
text-align: center;
padding: 0 15px;
margin-bottom: 24px;
}
.grid {
display: grid;
grid-gap: 8px;
grid-template-columns: repeat(2, 1fr);
grid-auto-rows: 30vw;
list-style: none;
}
.grid li:nth-child(9) {
grid-column: 1 / -1;
grid-row: span 2;
}
.grid figure,
.grid img {
width: 100%;
height: 100%;
}
.grid img {
object-fit: cover;
background: #f5f3f4;
box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.2);
}
@media (min-width: 850px) {
.grid {
grid-gap: 24px;
grid-template-columns: repeat(5, 1fr);
grid-auto-rows: 12vw;
}
.grid li:nth-child(1) {
grid-column: 1;
grid-row: 1 / span 2;
}
.grid li:nth-child(2) {
grid-column: 2 / span 2;
grid-row: 1 / span 2;
}
.grid li:nth-child(3) {
grid-column: 4;
grid-row: 1;
}
.grid li:nth-child(4) {
grid-column: 5;
grid-row: 1;
}
.grid li:nth-child(5) {
grid-column: 4;
grid-row: 2;
}
.grid li:nth-child(6) {
grid-column: 5;
grid-row: 2 / span 2;
}
.grid li:nth-child(7) {
grid-column: 2;
grid-row: 3;
}
.grid li:nth-child(8) {
grid-column: 1;
grid-row: 3;
}
.grid li:nth-child(9) {
grid-column: 3 / span 2;
grid-row: 3 / span 2;
}
.grid li:nth-child(10) {
grid-column: 1 / span 2;
grid-row: 4;
}
.grid li:nth-child(11) {
grid-column: 5;
grid-row: 4;
}
}
/* FOOTER STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-footer {
position: fixed;
right: 0;
bottom: 50px;
display: flex;
align-items: center;
padding: 5px;
z-index: 1;
color: black;
background: white;
}
.page-footer a {
display: flex;
margin-left: 4px;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.