Created
August 29, 2023 17:43
-
-
Save nikitadmitr/630d2a24d0178201c4547ee13a9e36c2 to your computer and use it in GitHub Desktop.
Masonry grid template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Image Gallery</title> | |
<style> | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
.container { | |
width: 1400px; | |
margin: 20px auto; | |
columns: 4; | |
column-gap: 20px; | |
} | |
.box { | |
width: 100%; | |
margin-bottom: 10px; | |
break-inside: avoid; | |
} | |
.box img { | |
max-width: 100%; | |
border-radius: 15px; | |
} | |
@media (max-width: 1400px) { | |
.container { | |
width: calc(100% - 40px); | |
columns: 3; | |
} | |
} | |
@media (max-width: 800px) { | |
.container { | |
columns: 2; | |
} | |
} | |
@media (max-width: 500px) { | |
.container { | |
columns: 1; | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="box"> | |
<img src="https://picsum.photos/600/1000" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/700" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/970" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/974" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/373" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/836" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/924" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/535" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/757" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/326" alt=""> | |
</div> | |
<div class="box"> | |
<img src="https://picsum.photos/600/753" alt=""> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment