Skip to content

Instantly share code, notes, and snippets.

@matt-daniel-brown
Created March 6, 2019 04:21
Show Gist options
  • Save matt-daniel-brown/565737dd20bee3f35a960d681711aeea to your computer and use it in GitHub Desktop.
Save matt-daniel-brown/565737dd20bee3f35a960d681711aeea to your computer and use it in GitHub Desktop.
Simple, Clean, Responsive, Semantic Grid (Gallery) Layout (using CSS Grids and Flexbox Fallback)
<main>
<section id="gallery-section">
<ul>
<li><img src="http://placehold.it/320x240" alt=""></li>
<li><img src="http://placehold.it/320x240" alt=""></li>
<li><img src="http://placehold.it/320x240" alt=""></li>
<li><img src="http://placehold.it/320x240" alt=""></li>
<li><img src="http://placehold.it/320x240" alt=""></li>
<li><img src="http://placehold.it/320x240" alt=""></li>
</ul>
</section>
</main>
* {
box-sizing: border-box;
}
body {
background: ghostwhite;
}
main {
padding: 5vw;
}
.container {
// background-color: #ddd;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
grid-gap: 1em;
}
img {
width: 100%;
align-self: center;
}
section#gallery-section {
ul {
@extend .container;
li {
img {
border-radius: 8px;
box-shadow: 0 8px 32px -8px rgba(gray, 0.5);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment