Scattered pictures
Photographs of different sizes placed freely on the page, drifting at their own speeds as it scrolls, with captions on hover.
Part of the style
Black Bar Grotesk
7 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/black-bar-grotesk/scatter/figma.html?palette=a00a69e670901cbb
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/black-bar-grotesk/scatter/figma.html?palette=a00a69e670901cbb and pass that whole HTML document to the html_to_figma tool, so the part "Scattered pictures" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
:root {
--ink: #c5c4c9;
--paper: #030303;
--ink-soft: #535251;
--veil: rgba(3, 3, 3, 0.5);
}
</style>
<section class="scatter" aria-label="Selected projects">
<a class="scatter__link" href="#">View projects <span class="scatter__plus" aria-hidden="true">+</span></a>
<div class="scatter__field">
<figure class="scatter__item" style="--x: 0%; --y: 6%; --w: 22%; --speed: 0.10">
<img class="scatter__photo" src="assets/pergola-2.jpg" alt="Rose arches over a pale garden path" width="800" height="533" loading="lazy">
<figcaption class="scatter__cap">Rose Walk, Annecy</figcaption>
</figure>
<figure class="scatter__item" style="--x: 30%; --y: 0%; --w: 30%; --speed: -0.06">
<img class="scatter__photo" src="assets/pavilion.jpg" alt="A timbered park pavilion with a clock tower, in snow" width="800" height="533" loading="lazy">
<figcaption class="scatter__cap">Tower Lawn, Winnipeg</figcaption>
</figure>
<figure class="scatter__item scatter__item--tall" style="--x: 74%; --y: 14%; --w: 26%; --speed: 0.14">
<img class="scatter__photo" src="assets/walking-path.jpg" alt="A sandy path curving through ferns under trees" width="800" height="600" loading="lazy">
<figcaption class="scatter__cap">Fern Hollow, Basel</figcaption>
</figure>
<figure class="scatter__item" style="--x: 12%; --y: 56%; --w: 28%; --speed: -0.1">
<img class="scatter__photo" src="assets/coast-path.jpg" alt="A path under rhododendrons near the coast" width="800" height="533" loading="lazy">
<figcaption class="scatter__cap">Cliff Garden, Turin</figcaption>
</figure>
<figure class="scatter__item" style="--x: 48%; --y: 50%; --w: 20%; --speed: 0.08">
<img class="scatter__photo" src="assets/shade-path.jpg" alt="A bark path through a shady planted bed" width="1000" height="750" loading="lazy">
<figcaption class="scatter__cap">Shade Court, Lyon</figcaption>
</figure>
</div>
</section>
<style>
.scatter {
padding: var(--space-l) var(--edge) var(--section-space);
}
.scatter__link {
display: flex;
align-items: center;
justify-content: center;
gap: 0.3em;
width: fit-content;
min-height: var(--tap);
margin: 0 auto var(--space-l);
color: var(--ink);
font-size: var(--text-xs);
font-weight: 700;
text-decoration: underline;
text-decoration-thickness: var(--rule);
text-underline-offset: 4px;
}
.scatter__plus {
display: inline-block;
transition: transform var(--quick) var(--ease);
}
.scatter__link:hover .scatter__plus,
.scatter__link:focus-visible .scatter__plus {
transform: rotate(90deg);
}
.scatter__field {
position: relative;
height: clamp(26rem, 52vw, 46rem);
}
.scatter__item {
position: absolute;
left: var(--x);
top: var(--y);
width: var(--w);
margin: 0;
transform: translateY(var(--drift, 0px));
will-change: transform;
}
.scatter__photo {
width: 100%;
height: auto;
aspect-ratio: 4 / 3;
object-fit: cover;
transition: filter var(--quick) var(--ease);
}
.scatter__item--tall .scatter__photo {
aspect-ratio: 3 / 4;
}
.scatter__cap {
margin-top: var(--space-xs);
font-size: var(--text-xs);
opacity: 0;
transition: opacity var(--quick) var(--ease);
}
.scatter__item:hover .scatter__cap {
opacity: 1;
}
@media (max-width: 40rem) {
.scatter__field {
height: auto;
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--space-l) var(--space-m);
}
.scatter__item {
position: static;
width: auto;
}
.scatter__item:nth-child(odd) { margin-top: var(--space-xl); }
.scatter__item:nth-child(3n) { grid-column: 1 / -1; width: 70%; justify-self: end; }
.scatter__cap { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.scatter__item { transform: none; }
}
</style>
<script>
(() => {
const still = matchMedia('(prefers-reduced-motion: reduce)');
for (const root of document.querySelectorAll('.scatter')) {
const items = [...root.querySelectorAll('.scatter__item')];
let visible = false;
let queued = false;
const place = () => {
queued = false;
if (!visible || still.matches) return;
const box = root.getBoundingClientRect();
const offset = Math.min(box.top, 0) + Math.max(box.top - innerHeight * 0.5, 0);
for (const item of items) {
const speed = parseFloat(getComputedStyle(item).getPropertyValue('--speed')) || 0;
item.style.setProperty('--drift', `${(offset * speed).toFixed(1)}px`);
}
};
const ask = () => { if (!queued) { queued = true; requestAnimationFrame(place); } };
new IntersectionObserver(([entry]) => { visible = entry.isIntersecting; ask(); }).observe(root);
addEventListener('scroll', ask, { passive: true });
addEventListener('resize', ask);
}
})();
</script>