Grid of thumbnails that open fullscreen on tap. Pure CSS using the :target pseudo-class — no JS.
Tap any tile to expand.
Each tile is a link to a hash like #lb1. Each lightbox is a fixed-position overlay with display: none by default. The CSS :target pseudo-class matches the element whose ID equals the URL hash, switching it to display: flex. Click the close (link to #) and the overlay disappears. Back button works too.
<div class="grid">
<a href="#lb1">Living room</a>
<a href="#lb2">Kitchen</a>
</div>
<div class="lightbox" id="lb1">
<a href="#" class="lb-close">×</a>
<div class="lightbox-img">Living room photo</div>
</div>
.lightbox { position: fixed; inset: 0; display: none; }
.lightbox:target { display: flex; }
.lb-close { position: absolute; top: 18px; right: 18px; }
Browser back to close — works automatically since each lightbox open is a new URL state. Back-swipe on iOS dismisses the overlay too. Free polish.
Prev/next in the lightbox — add prev/next links inside each lightbox pointing to #lb and #lb. Still pure CSS, no JS.
Add the rotate-phone hint — for landscape-optimal images, add a CSS-only "rotate your phone" SVG hint that only shows in portrait orientation (@media (orientation: portrait)). Peñaranda y Cobo does this on cinema images.
Compatibility: :target is in every modern browser. Back button integration is automatic. · Inspired by Peñaranda y Cobo's "Ampliar" lightbox.