Skip to content

Instantly share code, notes, and snippets.

@arosenkranz
Created March 1, 2022 14:36
Show Gist options
  • Save arosenkranz/3359c65fbfda36f17f622ff624b74aea to your computer and use it in GitHub Desktop.
Save arosenkranz/3359c65fbfda36f17f622ff624b74aea to your computer and use it in GitHub Desktop.
CSS Lightbox
<a href="#unique-id-of-image">
<img alt="alt text" src="../assets/filename.png" />
</a>
<a href="#" class="lightbox" id="unique-id-value">
<img alt="alt text" src="../assets/filename.png" />
</a>
.lightbox {
display: none;
position: fixed;
justify-content: center;
align-items: center;
z-index: 999;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 1rem;
background: rgba(0, 0, 0, 0.8);
}
.lightbox:target {
display: flex;
}
.lightbox img {
max-height: 100%
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment